Prepare btcprice for Kubernetes deployment

This commit is contained in:
2026-09-15 17:12:25 +02:00
parent dda00da77a
commit 573eba2d86
8 changed files with 619 additions and 11 deletions
+24 -1
View File
@@ -19,6 +19,9 @@ Optionally `cp .env.example .env` to override `BTCDATA_URL`; without it the code
(`http://localhost:4100`) applies. `make run-local` requires a `.env` defining
`BTCDATA_LOCAL_URL`.
Run the test suite with `make test`. Test-only packages are kept in `requirements-dev.txt` and are
not installed in the production image.
## Docker
`docker compose up -d` starts **btcprice only** — it does not bring up btcdata. Both compose
@@ -37,7 +40,19 @@ cd ../btcprice && docker compose up -d
Inside `btc-network`, btcprice reaches btcdata as `http://btcdata:4102`.
## Deployment (citadel)
## CI images
Pushes to the `main` branch and tags matching `v*` run
`.gitea/workflows/build.yml`. The workflow tests the application and publishes linux/amd64 images
to `harbor.pmagnus.cloud/btcprice/btcprice`. Branch builds receive an immutable
`main-<UTC timestamp>` tag (for Flux selection) and a SHA-qualified companion tag; release tags
receive the version without `v` and a SHA-qualified companion tag. The image embeds the short Git
SHA, available from `/api/version`.
The workflow requires the repository secrets `HARBOR_ROBOT_USER` and `HARBOR_ROBOT_TOKEN`. It only
pushes images and intentionally has no Kubernetes credentials.
## Legacy deployment (citadel)
```bash
./deploy-citadel.sh
@@ -62,6 +77,7 @@ Overridable: `BTCPRICE_DEPLOY_HOST`, `BTCPRICE_DEPLOY_DIR`, `BTCPRICE_IMAGE_NAME
| Variable | Default | Description |
|---|---|---|
| `BTCDATA_URL` | `http://localhost:4100` | btcdata service URL the server proxies to |
| `APP_VERSION` | `development` | Build identifier returned by `/api/version` |
| `BTCDATA_LOCAL_URL` | — | Used by `make run-local` instead of `BTCDATA_URL` |
| `DOCKER_BTCDATA_PORT` | `4102` | btcdata's port inside `btc-network` (local compose only) |
| `BTCPRICE_PORT` | `4041` | Host port in the citadel deployment (`.env.citadel`) |
@@ -69,6 +85,13 @@ Overridable: `BTCPRICE_DEPLOY_HOST`, `BTCPRICE_DEPLOY_DIR`, `BTCPRICE_IMAGE_NAME
The HTTP port is not configurable via environment: `make run` hardcodes 4000 and the Docker
image's `CMD` hardcodes 4040.
## Health endpoints
- `/api/health` is a process-only liveness check and remains healthy during a btcdata outage.
- `/api/ready` checks `${BTCDATA_URL}/api/health` with a three-second timeout and returns 503 when
btcdata is unavailable.
- `/api/version` returns the build SHA embedded by CI.
## How It Works
The browser loads a page with HTMX and the WebSocket extension, which connects back to