Files
OSIT-AE-Docker-Env/deploy.sh
Scott Idem dbfa9754d9 chore(deploy): add deploy.sh remote script, update Makefile
- deploy.sh: SSH-triggered deploy for prod and test environments on
  srv-nyx (linode.oneskyit.com). Pulls repos, builds ae_app container
  with correct BUILD_MODE, restarts ae_api.
- Makefile: rename build-ui → build-docker-dev/test/prod to match new
  naming convention; add deploy-remote-test and deploy-remote-prod targets
- .env.default: AE_APP_BUILD_MODE staging → dev (from prior session)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 17:18:52 -04:00

89 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# deploy.sh — Remote deploy for Aether Platform
# Run on srv-nyx directly, or triggered via SSH from the workstation.
#
# Usage: ./deploy.sh <prod|test> [app_branch] [api_branch]
# Example: ./deploy.sh prod
# ./deploy.sh test ae_app_3x_llm development
#
# From workstation (npm run deploy:remote:prod / deploy:remote:test):
# ssh linode.oneskyit.com 'bash /srv/env/prod_aether/deploy.sh prod'
# ssh linode.oneskyit.com 'bash /srv/env/test_aether/deploy.sh test'
#
# NOTE: bak_aether shares the same app/api dirs as prod.
# After a prod deploy, restart bak containers manually if running:
# cd /srv/env/bak_aether && docker compose restart ae_app ae_api
set -euo pipefail
ENV=${1:-}
if [ -z "$ENV" ]; then
echo "Usage: $0 <prod|test> [app_branch] [api_branch]"
exit 1
fi
# --- Environment config ---
# TODO: Update default branches once prod/test branch strategy is finalized.
# Currently both envs pull from the same working branches.
if [ "$ENV" = "prod" ]; then
APP_DIR=/srv/apps/prod_aether_app_sveltekit
API_DIR=/srv/apps/prod_aether_api_fastapi
COMPOSE_DIR=/srv/env/prod_aether
BUILD_MODE=prod
APP_BRANCH=${2:-ae_app_3x_llm}
API_BRANCH=${3:-development}
elif [ "$ENV" = "test" ]; then
APP_DIR=/srv/apps/test_aether_app_sveltekit
API_DIR=/srv/apps/test_aether_api_fastapi
COMPOSE_DIR=/srv/env/test_aether
BUILD_MODE=test
APP_BRANCH=${2:-ae_app_3x_llm}
API_BRANCH=${3:-development}
else
echo "Unknown environment: '$ENV' (expected: prod or test)"
exit 1
fi
echo ""
echo "========================================"
echo " Aether Deploy: $ENV"
echo " App: $APP_DIR [$APP_BRANCH]"
echo " API: $API_DIR [$API_BRANCH]"
echo " Mode: $BUILD_MODE"
echo "========================================"
echo ""
# --- Pull repos ---
echo "[1/4] Pulling container env..."
git -C "$COMPOSE_DIR" pull --ff-only
echo ""
echo "[2/4] Pulling app ($APP_BRANCH)..."
git -C "$APP_DIR" pull --ff-only origin "$APP_BRANCH"
echo ""
echo "[3/4] Pulling API ($API_BRANCH)..."
git -C "$API_DIR" pull --ff-only origin "$API_BRANCH"
# --- Build and deploy ---
echo ""
echo "[4/4] Building and deploying..."
cd "$COMPOSE_DIR"
docker compose build --build-arg BUILD_MODE="$BUILD_MODE" ae_app
docker compose up -d ae_app
docker compose restart ae_api
echo ""
echo "========================================"
echo " Done: $ENV deployed successfully"
echo "========================================"
if [ "$ENV" = "prod" ]; then
echo ""
echo " bak_aether uses the same code dirs — if its containers"
echo " are running, restart them:"
echo " cd /srv/env/bak_aether && docker compose restart ae_app ae_api"
fi
echo ""