Open-Generative-AI/Dockerfile
Anuragp22 6c2e52344d chore: add Docker setup with Postgres and worker services
Introduces a multi-stage Dockerfile for the Next.js app and a
docker-compose stack that provisions the app container alongside a
Postgres 16 instance and a dedicated worker container. This lays the
foundation for the upcoming batch-automation feature, which needs
persistent job state and a background process to drive MuAPI
submissions without blocking HTTP requests.

- Dockerfile: multi-stage build (deps / builder / runner), non-root user
- .dockerignore: excludes node_modules, .next, .git, electron artefacts
- docker-compose.yml:
    * postgres service with healthcheck + persistent volume
    * web service depends on postgres, passes DATABASE_URL
    * worker service runs worker/index.js (to be added in next slice)
2026-04-23 06:02:44 +05:30

37 lines
945 B
Docker

# syntax=docker/dockerfile:1.6
FROM node:20-alpine AS deps
WORKDIR /app
RUN apk add --no-cache libc6-compat
COPY package.json package-lock.json ./
COPY packages ./packages
RUN npm ci --legacy-peer-deps
FROM node:20-alpine AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/packages ./packages
COPY . .
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/package.json ./
COPY --from=builder /app/next.config.mjs ./
USER nextjs
EXPOSE 3000
CMD ["npm", "start"]