# Use the golang image to build the application FROM golang:1.22 AS builder ARG TARGETOS ARG TARGETARCH WORKDIR /workspace # Copy the Go Modules manifests COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy the go source files COPY cmd/ cmd/ COPY api/ api/ COPY config/ config/ COPY data/ data/ COPY integrations/ integrations/ # Build the Go application RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o backend ./cmd/main.go # Use distroless as minimal base image to package the application binary FROM gcr.io/distroless/static:nonroot WORKDIR / COPY --from=builder /workspace/backend ./ USER 65532:65532 # Expose port 4000 EXPOSE 4000 # Define environment variables ENV PORT 4000 ENV ENV development ENTRYPOINT ["/backend"]