Add a Dockerfile so the sync server is one command to deploy

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
This commit is contained in:
2026-10-08 10:23:54 +08:00
parent f3e6fc8fa6
commit cbdf5538aa
7 changed files with 132 additions and 3 deletions
+24
View File
@@ -28,6 +28,30 @@ The schema is created on startup. Every request is logged as
`METHOD PATH STATUS DURATION`; SIGTERM/SIGINT shut down gracefully so an
in-flight push is not cut off mid-write.
## Run with Docker
`docker-compose.yml` starts Postgres and the server together:
```bash
cd Server
POSTGRES_PASSWORD=$(openssl rand -hex 16) docker compose up -d
docker compose logs -f server # request log
```
Or build the image on its own and point it at an existing Postgres:
```bash
docker build -t prompt-sync Server/
docker run -d --name prompt-sync -p 8080:8080 \
-e PROMPT_SYNC_DATABASE_URL="postgres://user:pass@host:5432/prompt_sync?sslmode=disable" \
prompt-sync
```
The image is a static binary on `distroless` (non-root, no shell, ~6 MB binary),
so its `HEALTHCHECK` calls `prompt-sync -healthcheck`, which pings the local
`/healthz` and exits non-zero on failure — no curl needed in the image. That is
what `docker ps` reports as the container health.
## Deploy to a Linux host
```bash