CIA/e-voting-system/docker/Dockerfile.frontend
Alexis Bruneteau 68c0648cf1 fix: Update Docker config for Next.js frontend
- Updated Dockerfile.frontend to use Next.js instead of React CRA
- Multi-stage build for optimized image size
- Use NEXT_PUBLIC_API_URL instead of REACT_APP_API_URL
- Updated docker-compose.yml to pass correct env variable
- Frontend now starts with 'npm start' instead of serve

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 17:42:20 +01:00

37 lines
724 B
Docker

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY frontend/ .
# Build argument for API URL (Next.js uses NEXT_PUBLIC_)
ARG NEXT_PUBLIC_API_URL=http://backend:8000
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
# Build Next.js app
RUN npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Copy only necessary files from builder
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
EXPOSE 3000
# Start Next.js in production mode
CMD ["npm", "start"]