40 lines
1.2 KiB
Docker
Executable File
40 lines
1.2 KiB
Docker
Executable File
# Offline build: nothing in this file touches the network.
|
|
# - Go modules come from the committed vendor/ directory.
|
|
# - The runtime stage is postgres:14.1-alpine, the same image main-db uses,
|
|
# so pg_dump (backups), tzdata and CA certificates are already there and no
|
|
# `apk add` is needed. Its layers are shared with main-db on the server.
|
|
# The server only needs the base images loaded once (see `make docker-bundle`).
|
|
#
|
|
# No "# syntax=" directive on purpose: it makes BuildKit pull a frontend image.
|
|
|
|
FROM golang:1.26.4-alpine AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
ENV CGO_ENABLED=0 \
|
|
GOOS=linux \
|
|
GOARCH=amd64 \
|
|
GOFLAGS=-mod=vendor \
|
|
GOPROXY=off
|
|
|
|
COPY . .
|
|
|
|
RUN go build -trimpath -ldflags="-s -w" -o myapp ./app.go
|
|
|
|
FROM postgres:14.1-alpine
|
|
|
|
# Fresher CA bundle than the 2021 one in postgres:14.1-alpine (HTTPS to mpi.gov.tm).
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /build/myapp .
|
|
|
|
# config.yaml is mounted at runtime (see docker-compose.yaml), not baked in.
|
|
RUN mkdir -p /app/public/images /app/public/backups /app/logs
|
|
|
|
EXPOSE 5050
|
|
|
|
# Replaces the postgres docker-entrypoint.sh inherited from the base image.
|
|
ENTRYPOINT ["/app/myapp"]
|