Files
btcprice/deploy-citadel.sh
magnusandClaude Opus 5 864674bd09 Point citadel btcprice at the local btcdata over btc-network
omarchy is gone, but the citadel deployment still set
BTCDATA_URL=http://192.168.50.42:4102 and ran standalone on its own
compose network. Every request that proxies to btcdata failed with
httpx.ConnectError: All connection attempts failed.

btcdata now runs on citadel too, so attach btcprice to the external
btc-network there and reach it by service name at http://btcdata:4102.
deploy-citadel.sh creates the network on the remote if missing, as
btcdata's own deploy script already does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TRkiLhK5qhkZjP2adxpA3e
2026-09-11 18:52:49 +02:00

51 lines
1.5 KiB
Bash
Executable File

#!/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"
NETWORK="${BTCPRICE_NETWORK:-btc-network}"
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 "Ensuring external network $NETWORK exists on $HOST..."
ssh "$HOST" "docker network inspect '$NETWORK' >/dev/null 2>&1 || docker network create '$NETWORK'"
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"