From 2af8b6f62df924fa3f325ef7793521ee8e788d05 Mon Sep 17 00:00:00 2001 From: Per Magnus Petersen Date: Thu, 10 Sep 2026 14:24:38 +0200 Subject: [PATCH] Add citadel deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port of ../elprice/deploy-citadel.sh: build the image locally for the remote's architecture, ship it over SSH with docker save | docker load, and run docker compose up -d --no-build in /home/pmp/apps/btcprice. The deployment compose is standalone rather than joining btc-network, because citadel runs no btcdata — BTCDATA_URL points at the instance already running on omarchy (http://192.168.50.42:4102). Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01BdMTk61JgUdNH86ttMi4ce --- .env.citadel | 8 +++++++ CLAUDE.md | 11 +++++++++ README.md | 23 ++++++++++++++++++- deploy-citadel.sh | 46 ++++++++++++++++++++++++++++++++++++++ docker-compose.citadel.yml | 11 +++++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .env.citadel create mode 100755 deploy-citadel.sh create mode 100644 docker-compose.citadel.yml diff --git a/.env.citadel b/.env.citadel new file mode 100644 index 0000000..ac3d311 --- /dev/null +++ b/.env.citadel @@ -0,0 +1,8 @@ +# Environment for the citadel deployment. deploy-citadel.sh copies this to +# $APP_DIR/.env on the target host. No secrets — btcprice has none. + +# btcdata runs on omarchy (192.168.50.42), publishing its Docker port 4102. +BTCDATA_URL=http://192.168.50.42:4102 + +# Host port; container always listens on 4040. +BTCPRICE_PORT=4041 diff --git a/CLAUDE.md b/CLAUDE.md index bf44591..4a7fad3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,6 +31,17 @@ Note: `Dockerfile` bakes in a stale `ENV BTCDATA_URL=http://btcdata:4101`; compo overrides it, so it only matters if the image is run outside compose. `ENV PORT` is likewise unused — the port in `CMD` is hardcoded. +## Deployment + +`./deploy-citadel.sh` — build locally for the remote's arch, `docker save | ssh docker load`, +`docker compose up -d --no-build` in `/home/pmp/apps/btcprice` on citadel (192.168.50.195). +Mirrors `../elprice/deploy-citadel.sh`; no registry. + +- `docker-compose.citadel.yml` → remote `docker-compose.yml`; `.env.citadel` → remote `.env`. +- Standalone (no `btc-network`): citadel has no btcdata, so `BTCDATA_URL` points at the btcdata + on omarchy, `http://192.168.50.42:4102`. +- Live at http://192.168.50.195:4041. A separate btcprice also still runs on omarchy at :4041. + ## Architecture - **Framework:** FastAPI diff --git a/README.md b/README.md index e754e99..619dc2c 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,34 @@ cd ../btcprice && docker compose up -d Inside `btc-network`, btcprice reaches btcdata as `http://btcdata:4102`. +## Deployment (citadel) + +```bash +./deploy-citadel.sh +``` + +Same method as `../elprice/deploy-citadel.sh`: builds the image locally for the target's +architecture (citadel is x86_64 → `linux/amd64`), copies `docker-compose.citadel.yml` and +`.env.citadel` to `/home/pmp/apps/btcprice` on the host as `docker-compose.yml` / `.env`, +pipes the image over SSH with `docker save | docker load`, and runs +`docker compose up -d --no-build`. No registry involved. + +Deployed btcprice listens on **http://192.168.50.195:4041** and proxies to the btcdata already +running on omarchy (`http://192.168.50.42:4102`, set via `BTCDATA_URL` in `.env.citadel`) — +citadel runs no btcdata of its own, so the deployment compose is standalone with no +`btc-network`. + +Overridable: `BTCPRICE_DEPLOY_HOST`, `BTCPRICE_DEPLOY_DIR`, `BTCPRICE_IMAGE_NAME`, +`BTCPRICE_PLATFORM`. + ## Environment Variables | Variable | Default | Description | |---|---|---| | `BTCDATA_URL` | `http://localhost:4100` | btcdata service URL the server proxies to | | `BTCDATA_LOCAL_URL` | — | Used by `make run-local` instead of `BTCDATA_URL` | -| `DOCKER_BTCDATA_PORT` | `4102` | btcdata's port inside `btc-network` (compose only) | +| `DOCKER_BTCDATA_PORT` | `4102` | btcdata's port inside `btc-network` (local compose only) | +| `BTCPRICE_PORT` | `4041` | Host port in the citadel deployment (`.env.citadel`) | The HTTP port is not configurable via environment: `make run` hardcodes 4000 and the Docker image's `CMD` hardcodes 4040. diff --git a/deploy-citadel.sh b/deploy-citadel.sh new file mode 100755 index 0000000..41c6060 --- /dev/null +++ b/deploy-citadel.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +HOST="${BTCPRICE_DEPLOY_HOST:-citadel}" +APP_DIR="${BTCPRICE_DEPLOY_DIR:-/home/pmp/apps/btcprice}" +IMAGE_NAME="${BTCPRICE_IMAGE_NAME:-btcprice:latest}" +PLATFORM="${BTCPRICE_PLATFORM:-}" +COMPOSE_FILE="docker-compose.citadel.yml" +ENV_FILE=".env.citadel" +FILES=("$COMPOSE_FILE" "$ENV_FILE") + +if [[ -z "$PLATFORM" ]]; then + remote_arch="$(ssh "$HOST" uname -m)" + case "$remote_arch" in + x86_64 | amd64) PLATFORM="linux/amd64" ;; + aarch64 | arm64) PLATFORM="linux/arm64" ;; + *) + echo "Unsupported target architecture: $remote_arch" >&2 + echo "Set BTCPRICE_PLATFORM manually, e.g. BTCPRICE_PLATFORM=linux/amd64" >&2 + exit 1 + ;; + esac +fi + +for file in "${FILES[@]}"; do + if [[ ! -f "$file" ]]; then + echo "Missing required file: $file" >&2 + exit 1 + fi +done + +echo "Building $IMAGE_NAME locally for $PLATFORM..." +docker build --platform "$PLATFORM" -t "$IMAGE_NAME" . + +echo "Preparing $APP_DIR on $HOST..." +ssh "$HOST" "mkdir -p '$APP_DIR'" + +echo "Copying $COMPOSE_FILE and $ENV_FILE to $HOST:$APP_DIR..." +scp "$COMPOSE_FILE" "$HOST:$APP_DIR/docker-compose.yml" +scp "$ENV_FILE" "$HOST:$APP_DIR/.env" + +echo "Copying Docker image $IMAGE_NAME to $HOST..." +docker save "$IMAGE_NAME" | ssh "$HOST" docker load + +echo "Starting docker compose on $HOST in $APP_DIR..." +ssh "$HOST" "cd '$APP_DIR' && docker compose up -d --no-build" diff --git a/docker-compose.citadel.yml b/docker-compose.citadel.yml new file mode 100644 index 0000000..0be161a --- /dev/null +++ b/docker-compose.citadel.yml @@ -0,0 +1,11 @@ +# Deployment compose for citadel. Copied to $APP_DIR/docker-compose.yml by +# deploy-citadel.sh, which also copies .env.citadel to $APP_DIR/.env. +# Standalone: btcdata is remote, so no btc-network here. +services: + btcprice: + image: btcprice:latest + restart: unless-stopped + ports: + - "${BTCPRICE_PORT:-4041}:4040" + environment: + BTCDATA_URL: "${BTCDATA_URL:?set BTCDATA_URL in .env}"