peppa/template/deploy/Dockerfile.go

20 lines
991 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Заготовка для Go (FORGE Default Stack, PEP-314). Скопируй в ./Dockerfile и поправь под проект.
# Приложение слушает $PORT и отвечает 200 на GET /healthz (deploy.health).
# Итог — статический бинарь /app/server в distroless: оболочки в образе нет, поэтому миграция —
# массивом в .peppa/project.json: "migrate": ["/app/server", "migrate"]. CMD, а не ENTRYPOINT:
# так `docker compose run web /app/server migrate` заменяет команду, а не дописывается к ней.
ARG GO_VERSION=1.27
FROM golang:${GO_VERSION}-bookworm AS build
WORKDIR /src
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/server /app/server
ENV PORT=3000
EXPOSE 3000
USER nonroot
CMD ["/app/server"]