From dbfa9754d92cc31f1db7d386fa15408813b3cd6e Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 26 Mar 2026 17:18:52 -0400 Subject: [PATCH] chore(deploy): add deploy.sh remote script, update Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .env.default | 2 +- Makefile | 22 +++++++++++-- deploy.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) create mode 100755 deploy.sh diff --git a/.env.default b/.env.default index 3857ac7..28b3d08 100644 --- a/.env.default +++ b/.env.default @@ -134,7 +134,7 @@ AE_SMTP_PASSWORD=XXXX # APP SETTINGS (SvelteKit) # ------------------------------------------------------------------------------ AE_APP_ENV=development -AE_APP_BUILD_MODE=staging +AE_APP_BUILD_MODE=dev AE_APP_REPLICAS=2 # AE App (Node SvelteKit) Gateway Port for External Reverse Proxy AE_APP_GATEWAY_PORT=3001 diff --git a/Makefile b/Makefile index 46214ab..4d25d13 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Aether Platform - Operations Makefile # Use these shortcuts for faster development and deployment. -.PHONY: up down restart-api build-api build-ui logs ps +.PHONY: up down restart-api build-api build-docker-dev build-docker-test build-docker-prod logs ps deploy-remote-test deploy-remote-prod # Start the entire stack up: @@ -21,10 +21,18 @@ restart-api: build-api: docker compose up -d --build ae_api -# REBUILD UI: Standard autonomous build for SvelteKit -build-ui: +# BUILD DOCKER UI: Build the SvelteKit container for the given mode. +# Use 'npm run dev' for active development (Vite HMR, no Docker). +# Use these only when testing the production-like Docker build locally. +build-docker-dev: docker compose build ae_app && docker compose up -d ae_app +build-docker-test: + docker compose build --build-arg BUILD_MODE=test ae_app && docker compose up -d ae_app + +build-docker-prod: + docker compose build --build-arg BUILD_MODE=prod ae_app && docker compose up -d --remove-orphans ae_app + # View combined logs logs: docker compose logs -f --tail=100 @@ -32,3 +40,11 @@ logs: # Check service status ps: docker compose ps + +# Remote deploy (SSH to linode.oneskyit.com, run deploy.sh) +# Requires key-based SSH and deploy.sh committed + pulled on the server. +deploy-remote-test: + ssh linode.oneskyit.com 'bash /srv/env/test_aether/deploy.sh test' + +deploy-remote-prod: + ssh linode.oneskyit.com 'bash /srv/env/prod_aether/deploy.sh prod' diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..a44baf9 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# deploy.sh — Remote deploy for Aether Platform +# Run on srv-nyx directly, or triggered via SSH from the workstation. +# +# Usage: ./deploy.sh [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 [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 ""