# client/Dockerfile # 1. Use an official Node.js image as the base FROM node:19-alpine AS builder # 2. Create and set the working directory WORKDIR /app # 3. Copy package manifests and install dependencies COPY package*.json ./ RUN npm install # 4. Copy your Next.js source code COPY . . # 5. Build the Next.js app RUN npm run build # 6. Use a lightweight webserver for the final image (or continue with Node SSR) # Option A: If you use Next.js "standalone" + "output: 'standalone'" in next.config.js: # https://nextjs.org/docs/advanced-features/output-file-tracing # Option B: Run Next.js in Node as usual. # We'll do SSR with Node below. FROM node:19-alpine AS runner WORKDIR /app # Copy the build output from the builder COPY --from=builder /app/.next ./.next COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package*.json ./ COPY --from=builder /app/public ./public COPY --from=builder /app/config.json ./ EXPOSE 3000 # For SSR, we run Next.js in Node: CMD ["npm", "run", "start"]