build(sidecar): containerize + delete the Node prototype

- New sidecar/Dockerfile: multi-stage golang:1.25-alpine → distroless/
  static, ~12 MB final image, static CGO-free binary.
- Wire pp-sidecar into docker-compose.photoprism.yml so the whole
  stack (mariadb + photoprism + sidecar) starts with one
  `podman-compose up`. Container reaches mariadb + photoprism on the
  internal network; the host gets 127.0.0.1:8000 for Vite's proxy.
- New SIDECAR_LISTEN_ADDR env var (default 127.0.0.1 for the host-mode
  dev loop) so the container can bind 0.0.0.0:8000 and let the port
  mapping reach it. Without this the loopback bind was invisible to
  the host.
- Delete sidecar/legacy/server.mjs — the Node prototype's archival
  window is over; git history is its home now.
- Update sidecar/README with compose-first bringup; keep the host
  `go build` flow as the fast-iteration loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 17:23:36 +02:00
parent 032dce6c85
commit 4362e475a7
7 changed files with 113 additions and 852 deletions

View File

@@ -31,7 +31,27 @@ Marks persist to **MariaDB** (`mule_sidecar.marks`); everything else
operates on the filesystem under `${ORIGINALS_ROOT}` and triggers a
PhotoPrism reindex of the affected parent in the background.
## Build & run
## Run
The sidecar is a `sidecar` service in the PhotoPrism compose stack.
Bringing the whole stack up brings it up too:
```sh
podman-compose --env-file .env.photoprism \
-f docker-compose.photoprism.yml \
-f docker-compose.photoprism.podman.yml \
up -d
```
This builds [Dockerfile](Dockerfile) (multi-stage `golang:1.25-alpine`
`gcr.io/distroless/static`, ~12 MB final image), starts the container,
and binds `127.0.0.1:8000` to the service. The SvelteKit dev server
proxies `/api/sidecar/*` to that port transparently.
### Dev-iteration loop (host build)
For tight iteration without rebuilding the image on every change you
can run it as a host process — Go is already on the dev machine:
```sh
cd sidecar
@@ -43,8 +63,8 @@ SIDECAR_PORT=8000 \
./mule-sidecar
```
The SvelteKit dev server proxies `/api/sidecar/*` to
`http://localhost:8000`.
The host build connects to `mariadb` via the loopback port the compose
file publishes; stop `pp-sidecar` first so they don't fight for 8000.
## Env
@@ -81,6 +101,7 @@ state. Heap-sharing tables (M4) will land in subsequent migrations.
```text
sidecar/
├── Dockerfile multi-stage golang:1.25 → distroless/static
├── main.go entrypoint, route wiring, graceful shutdown
├── config.go env-driven Config
├── db.go GORM open + Mark model + AutoMigrate
@@ -91,6 +112,5 @@ sidecar/
├── handlers_folders.go
├── handlers_marks.go
├── handlers_heap.go
── handlers_dups.go
└── legacy/server.mjs Node prototype, retained for one cycle as a reference.
── handlers_dups.go
```