infoalloggi-monorepo/apps/db-backup/Dockerfile
2026-05-26 10:42:00 +02:00

24 lines
No EOL
551 B
Docker

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"]