# API Service Dockerfile FROM golang:1.21-alpine AS builder WORKDIR /build # Copy go workspace COPY go.work* ./ COPY go.mod* ./services/api/ COPY go.sum* ./services/api/ 2>/dev/null || true # Copy shared packages COPY pkg/ ./pkg/ # Copy service COPY services/api/ ./services/api/ # Build WORKDIR /build/services/api RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /app/api . # Final image FROM alpine:3.18 RUN apk --no-cache add ca-certificates curl WORKDIR /app COPY --from=builder /app/api . # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8080/health || exit 1 EXPOSE 8080 CMD ["/app/api"]