# Static binary (CGO_ENABLED=0) on a slim base. ca-certificates for outbound # HTTPS; the cache mounts keep rebuilds fast. FROM golang:1.26 AS builder WORKDIR /backend COPY go.mod go.sum ./ RUN --mount=type=cache,target=/go/pkg/mod \ go mod download COPY . ./ RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 go build -o main . FROM debian:bookworm-slim # For the compose healthcheck. RUN apt-get update \ && apt-get install --yes --no-install-recommends ca-certificates wget \ && rm -rf /var/lib/apt/lists/* WORKDIR /backend COPY --from=builder /backend/main ./main EXPOSE 8080 CMD ["./main"]