From a6d689b312939c753337bacaa4f2321e855403fb Mon Sep 17 00:00:00 2001 From: eleith Date: Mon, 23 Nov 2026 06:46:48 -0800 Subject: [PATCH] ops: add a standalone Compose deployment --- README.md | 31 ++++++++++++++-------------- compose.yaml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 compose.yaml diff --git a/README.md b/README.md index f2555e4..4fe7c78 100644 --- a/README.md +++ b/README.md @@ -6,37 +6,42 @@ One YAML file can run links for several domains. The admin shows what’s config ## Get started -Let’s assume you have Docker Compose. From a checkout: +You’ll need Docker Compose and an HTTPS reverse proxy that can reach the Docker host’s loopback address, such as a proxy running directly on that host. Download the [Compose file](compose.yaml). No checkout or build needed. ```sh -mkdir -p apps/web/config apps/web/data +mkdir -p goto/config goto/data +cd goto +curl -fsSLo compose.yaml https://git.eleith.com/eleith/goto/raw/branch/main/compose.yaml ``` -Save this as `apps/web/config/goto.yaml`. Pick a password before starting. +Save this as `config/goto.yaml`. Replace `go.example.org` with your host in both places. ```yaml url: - app: http://localhost:5173 + app: https://go.example.org auth: + secret: '${GOTO_AUTH_SECRET}' credentials: username: admin - password: 'pick-a-local-password' + password: '${GOTO_ADMIN_PASSWORD}' domains: - localhost:5173: + go.example.org: links: /hello: url: https://example.org ``` -If your user and group IDs aren’t `1000:1000`, set `LOCAL_UID` and `LOCAL_GID` before running Compose. +Put `GOTO_ADMIN_PASSWORD` and `GOTO_AUTH_SECRET` in `.env` beside `compose.yaml`. Pick a password and generate a secret with `openssl rand -hex 32`. Keep the same secret across restarts. Make `data/` writable by the containers (UID `1000` on Linux) and back it up. + +Point your HTTPS proxy at `http://127.0.0.1:3000`. Preserve `Host` and have the proxy set `X-Real-IP`. The worker isn’t exposed. ```sh -docker compose -f apps/web/docker-compose.dev.yml up --build --wait +docker compose up --wait ``` -When the command finishes, open . It should send you on your way. Sign in at to see the link. The worker prepares Analytics in the background, so don’t stare at the chart waiting for that first click. +Open `/hello` on your host. It should send you on your way. Sign in at `/admin` to see the link. The worker prepares Analytics in the background, so don’t stare at the chart waiting for that first click. ## Why this way? @@ -46,13 +51,9 @@ When the command finishes, open . It should send yo **What gets kept?** Analytics keeps 90 days of detail by default. Set `analytics.retention_months: 0` to turn off detailed Analytics without losing lifetime totals. Stop both services before reducing retention or switching between zero and a positive value, then start them again. -## Configuration and deployment +## Configuration -The [example YAML](examples/goto.yaml) shows multiple domains, SSO, tags and conditional redirects. The [schema](packages/config/src/config.schema.json) has the full list of options. Most link edits take effect without a restart. - -Use the [production Compose file](apps/web/docker-compose.yml) behind an HTTPS reverse proxy. Set `url.app` to the public admin origin and put your short-link hosts under `domains`. They can share a host or use separate ones. Keep the backend private; have the proxy preserve `Host` and set `X-Forwarded-Proto` and `X-Real-IP`. Put `PROTOCOL_HEADER=X-Forwarded-Proto` in `apps/web/.env`. - -Keep `apps/web/data` writable by both containers and backed up. Use a stable, random `auth.secret` of at least 32 characters, passed in through the environment as in the example. +Admin and short links can share a host or use separate ones. The [example YAML](examples/goto.yaml) shows multiple domains, SSO, tags and conditional redirects. The [schema](packages/config/src/config.schema.json) has the full list. Most link edits take effect without a restart. ## Development diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..bf737ff --- /dev/null +++ b/compose.yaml @@ -0,0 +1,57 @@ +services: + goto-app: + image: ghcr.io/eleith/goto:latest + platform: linux/amd64 + env_file: .env + ports: + - '127.0.0.1:3000:3000' + volumes: + - ./config:/app/config:ro + - ./data:/app/data + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=16m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + restart: unless-stopped + depends_on: + goto-worker: + condition: service_healthy + healthcheck: + test: + - CMD + - node + - --eval + - fetch('http://localhost:3000/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1)) + interval: 30s + timeout: 3s + start_period: 5s + retries: 3 + + goto-worker: + image: ghcr.io/eleith/goto-worker:latest + platform: linux/amd64 + env_file: .env + volumes: + - ./config:/app/config:ro + - ./data:/app/data + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=16m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + restart: unless-stopped + healthcheck: + test: + - CMD + - node + - --eval + - fetch('http://localhost:9000/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1)) + interval: 30s + timeout: 3s + start_period: 5s + retries: 3 -- 2.54.1