Drop the compose file and systemd unit for the sync server

The server is a single process, so a compose file that only wrapped one
container added a second way to do the same thing. Docker is now the one
documented path, pointing at a Postgres that lives outside the container.

💘 Generated with Crush

Assisted-by: Crush:kimi-k3
This commit is contained in:
2026-10-08 10:25:21 +08:00
parent cbdf5538aa
commit c0dd211ee5
5 changed files with 30 additions and 90 deletions
+22 -23
View File
@@ -30,41 +30,40 @@ 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:
The image is a static binary on `distroless` (non-root, no shell), so its
`HEALTHCHECK` calls `prompt-sync -healthcheck`, which pings the local
`/healthz` — no curl needed in the image. That is what `docker ps` reports as
the container health.
```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
docker logs -f prompt-sync # request log
```
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.
Postgres stays outside the container; the server only needs a URL. If Postgres
runs on the Docker host itself, `host` is `host.docker.internal` on macOS and
Windows, or the host's LAN address on Linux (`--network host` also works).
## Deploy to a Linux host
## Deploy to a host
Build for the host's architecture and ship the image, or build it on the host
itself (a `git clone` plus `docker build` is usually simplest):
```bash
# from the repo root, on the Mac
cd Server
GOOS=linux GOARCH=arm64 go build -o prompt-sync . # amd64 for x86 hosts
scp prompt-sync <host>:/tmp/ && ssh <host> 'sudo mv /tmp/prompt-sync /usr/local/bin/'
# build on the Mac for a linux/arm64 host, then copy it over
docker build --platform linux/arm64 -t prompt-sync Server/
docker save prompt-sync | gzip > prompt-sync.tar.gz
scp prompt-sync.tar.gz <host>:
ssh <host> 'gunzip -c prompt-sync.tar.gz | docker load'
# on the host: create the database and role, then
sudo cp Server/prompt-sync.service /etc/systemd/system/
sudo systemctl edit --full prompt-sync # set PROMPT_SYNC_DATABASE_URL
sudo systemctl enable --now prompt-sync
journalctl -u prompt-sync -f # verify it is listening
ssh <host> 'docker run -d --name prompt-sync --restart unless-stopped \
-p 8080:8080 \
-e PROMPT_SYNC_DATABASE_URL="postgres://user:pass@db-host:5432/prompt_sync?sslmode=disable" \
prompt-sync'
```
Put it behind TLS if it is reachable from the internet — the code is the only