Self-hosting meant building the binary by hand and wiring Postgres up
yourself. The image is a static binary on distroless with a built-in
healthcheck flag, and docker-compose brings up Postgres alongside it.
The image itself is unbuilt here: no container runtime is available in
this environment, so only the static Linux build and the healthcheck
flag have been exercised.
💘 Generated with Crush
Assisted-by: Crush:kimi-k3
28 lines
808 B
Docker
28 lines
808 B
Docker
# Build stage: the server is pure Go (lib/pq is pure Go), so CGO is off and the
|
|
# result is a static binary that runs on a shell-less base image.
|
|
FROM golang:1.26-alpine AS build
|
|
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY *.go ./
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
|
|
go build -trimpath -ldflags="-s -w" -o /prompt-sync .
|
|
|
|
# Runtime stage: distroless has no shell, so the binary does its own
|
|
# healthcheck (see -healthcheck in main.go). Runs as non-root.
|
|
FROM gcr.io/distroless/static-debian12:nonroot
|
|
|
|
COPY --from=build /prompt-sync /prompt-sync
|
|
|
|
ENV PROMPT_SYNC_ADDR=:8080
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD ["/prompt-sync", "-healthcheck"]
|
|
|
|
ENTRYPOINT ["/prompt-sync"]
|