From b9454df5c9ec0b897d7f0a1163fafd228cea3bcc Mon Sep 17 00:00:00 2001 From: Mohan Ki Date: Mon, 27 Jul 2026 13:53:10 +0530 Subject: [PATCH] Update docker config for production deployment --- api/Dockerfile | 10 ++++++++++ client/Dockerfile | 24 ++++++++++++++++++++++++ client/next.config.ts | 1 + docker-compose.yml | 11 ++--------- 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 api/Dockerfile create mode 100644 client/Dockerfile diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..9457cb4 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,10 @@ +FROM node:18-alpine + +WORKDIR /app + +COPY package*.json ./ +RUN npm install --production + +COPY . . + +CMD ["npm", "start"] diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..87db036 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,24 @@ +FROM node:18-alpine AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM node:18-alpine AS runner +WORKDIR /app + +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +COPY --from=builder /app/public ./public + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +EXPOSE 4000 +ENV PORT 4000 + +CMD ["node", "server.js"] diff --git a/client/next.config.ts b/client/next.config.ts index 4a2bdf6..36a174f 100644 --- a/client/next.config.ts +++ b/client/next.config.ts @@ -5,6 +5,7 @@ const nextConfig: NextConfig = { appIsrStatus: false, buildActivity: false, }, + output: 'standalone', }; export default nextConfig; diff --git a/docker-compose.yml b/docker-compose.yml index 7906352..040519b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,12 +4,9 @@ services: frontend: build: context: ./client - dockerfile: Dockerfile.dev + dockerfile: Dockerfile ports: - "4000:4000" - volumes: - - ./client:/app - - /app/node_modules environment: - PORT=4000 depends_on: @@ -18,13 +15,9 @@ services: backend: build: context: ./api - dockerfile: Dockerfile.dev + dockerfile: Dockerfile ports: - "4001:4001" - - "9229:9229" - volumes: - - ./api:/app - - /app/node_modules environment: - PORT=4001 - PGHOST=postgres