# syntax=docker/dockerfile:1 # Stage 1: Build Frontend FROM node:26 AS frontend-builder ARG API_HTTP_PORT=8080 WORKDIR /app/front # Copy frontend package files and install dependencies COPY front/package.json front/pnpm-lock.yaml ./ RUN corepack enable && pnpm install --frozen-lockfile # Copy frontend source and build COPY docs/* ../docs/ COPY front/ ./ # Create .env.production with the API URL # Use /api for production to go through nginx proxy (avoids CORS issues) RUN echo "REACT_APP_REQUEST_INBOX_API_URL=/api" > .env.production RUN pnpm build # Stage 2: Build Backend FROM golang:1.27.3-alpine AS backend-builder RUN apk update && \ apk add --no-cache --no-progress \ ca-certificates \ bash \ gcc \ make \ musl-dev \ curl \ tar \ tzdata \ git \ && rm -rf /var/cache/apk/* && update-ca-certificates WORKDIR /github.com/jesusnoseq/request-inbox/ # Copy Go module files and download dependencies COPY api/go.mod api/go.sum ./api/ RUN cd api && go mod download # Copy API source code COPY api ./api # Build the API RUN cd api && CGO_ENABLED=0 GOOS=linux go build -tags=jsoniter -ldflags="-w -s" -o main cmd/main.go # Stage 3: Final Runtime Image FROM nginx:1.30.6-alpine RUN apk --no-cache add ca-certificates tzdata supervisor && \ rm -rf /var/cache/apk/* WORKDIR /app # Copy backend binary from builder COPY --from=backend-builder /github.com/jesusnoseq/request-inbox/api/main ./api # Copy frontend build to nginx html directory COPY --from=frontend-builder /app/front/build /usr/share/nginx/html # Create directory for embedded database RUN mkdir -p /app/data && \ chown -R nginx:nginx /app/data # Copy nginx configuration COPY < /etc/supervisord.conf < /entrypoint.sh && \ chmod +x /entrypoint.sh # Expose ports 80 (nginx) and 8080 (Go API) EXPOSE 80 8080 # Override nginx entrypoint and run our script ENTRYPOINT ["/entrypoint.sh"] CMD []