# Multi-stage build for full-stack task manager # This Dockerfile builds both backend and frontend # ============== BACKEND BUILD ============== FROM golang:1.22-alpine AS backend-builder WORKDIR /app/backend RUN apk add --no-cache git COPY backend/go.mod backend/go.sum* ./ RUN go mod download COPY backend/ . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . # ============== FRONTEND BUILD ============== FROM node:20-alpine AS frontend-deps WORKDIR /app COPY frontend/package.json frontend/package-lock.json* ./ RUN npm ci || npm install FROM node:20-alpine AS frontend-builder WORKDIR /app COPY --from=frontend-deps /app/node_modules ./node_modules COPY frontend/ . ENV NEXT_TELEMETRY_DISABLED=1 RUN npm run build # ============== FINAL STAGE ============== FROM alpine:3.19 WORKDIR /app # Install nginx, nodejs, and supervisor RUN apk --no-cache add ca-certificates nginx nodejs npm supervisor # Copy backend binary COPY --from=backend-builder /app/backend/main ./backend/main # Copy frontend COPY --from=frontend-builder /app/.next/standalone ./frontend/ COPY --from=frontend-builder /app/.next/static ./frontend/.next/static COPY --from=frontend-builder /app/public ./frontend/public # Create nginx config for reverse proxy RUN mkdir -p /etc/nginx/http.d COPY <