File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ COPY . .
1818
1919# Environment variables for build
2020ENV NEXT_TELEMETRY_DISABLED 1
21- ENV NEXT_PUBLIC_API_URL=http://localhost:8000
21+ # Fix #7: Use Docker service name 'backend' instead of localhost
22+ # 'localhost' does not resolve to the backend container at build time
23+ ENV NEXT_PUBLIC_API_URL=http://backend:8000
2224
2325# Build the application
2426RUN npm run build
@@ -30,27 +32,17 @@ WORKDIR /app
3032ENV NODE_ENV production
3133ENV NEXT_TELEMETRY_DISABLED 1
3234
33- # Create a non-root user
35+ # Create non-root user for security
3436RUN addgroup --system --gid 1001 nodejs
3537RUN adduser --system --uid 1001 nextjs
3638
37- # Copy built application
3839COPY --from=builder /app/public ./public
3940COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
4041COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
4142
42- # Switch to non-root user
4343USER nextjs
4444
45- # Expose port
4645EXPOSE 3000
47-
4846ENV PORT 3000
49- ENV HOSTNAME "0.0.0.0"
50-
51- # Health check
52- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
53- CMD node -e "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
5447
55- # Run the application
5648CMD ["node" , "server.js" ]
You can’t perform that action at this time.
0 commit comments