FROM golang:1.25-alpine AS builder WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY main.go . # Compile a highly optimized, completely static binary RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o backup-app main.go # --- Stage 2: Final Light Execution Layer --- FROM postgres:18-alpine WORKDIR /app # Copy the compiled executable from the builder layer COPY --from=builder /src/backup-app . # Set up environmental time out-of-the-box ENV TZ=Europe/Rome ENV PGTZ=Europe/Rome ENTRYPOINT ["/app/backup-app"] CMD ["cron-init"]