# Build stage FROM golang:1.21-alpine AS builder RUN apk add --no-cache git ca-certificates # Set Go proxy (can be overridden with --build-arg GOPROXY=...) ARG GOPROXY=https://proxy.golang.org,direct ENV GOPROXY=${GOPROXY} WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ -ldflags="-w -s" \ -o /bin/account-service \ ./services/account/cmd/server # Final stage FROM alpine:3.18 RUN apk --no-cache add ca-certificates curl RUN adduser -D -s /bin/sh mpc COPY --from=builder /bin/account-service /bin/account-service USER mpc EXPOSE 50051 8080 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -sf http://localhost:8080/health || exit 1 ENTRYPOINT ["/bin/account-service"]