This repository has no description
1.5 kB
38 lines
1# syntax=docker/dockerfile:1
2# Go XRPC service (cmd/puzzlemethis). The SvelteKit client has its own
3# Dockerfile in client/; docker-compose.yml runs both.
4#
5# Example:
6# docker build -t puzzlemethis-api .
7# docker run -p 8080:8080 -v ./data:/data \
8# -e SERVICE_DID=did:web:api.example.com \
9# -e SERVICE_HOST=api.example.com \
10# -e SERVICE_PRIVATE_KEY=... puzzlemethis-api
11
12FROM golang:1.26-bookworm AS build
13WORKDIR /src
14COPY go.mod go.sum ./
15RUN go mod download
16COPY . .
17# mattn/go-sqlite3 compiles SQLite from C source: CGO is required, and the
18# runtime image only needs a matching glibc (hence bookworm on both stages),
19# no libsqlite3 package. themes.xml and board-image sprites are go:embed'd.
20RUN CGO_ENABLED=1 go build -trimpath -o /out/puzzlemethis ./cmd/puzzlemethis
21
22FROM debian:bookworm-slim
23# curl is for the compose healthcheck; ca-certificates for HTTPS to PLC/slingshot.
24RUN apt-get update \
25 && apt-get install -y --no-install-recommends ca-certificates curl \
26 && rm -rf /var/lib/apt/lists/* \
27 && useradd --uid 1000 --create-home app
28COPY --from=build /out/puzzlemethis /usr/local/bin/
29# /data holds the SQLite db plus its WAL sidecars — mount a directory there
30# that uid 1000 can write.
31ENV SERVER_HOST=0.0.0.0 \
32 DATABASE_URL=/data/puzzles.db \
33 LOG_FORMAT=json
34USER app
35EXPOSE 8080
36# Exec form so SIGTERM reaches the process directly — the server checkpoints
37# the WAL on graceful shutdown.
38ENTRYPOINT ["/usr/local/bin/puzzlemethis"]