#!/bin/bash # Deploy soleprint standalone to server # # Usage: # ./ctrl/deploy.sh # Sync and restart # ./ctrl/deploy.sh --build # Rebuild locally first, then sync and restart # ./ctrl/deploy.sh --sync-only # Sync without restarting set -e cd "$(dirname "$0")/.." SERVER="mcrn.ar" REMOTE_DIR="~/soleprint/gen/standalone" BUILD=false SYNC_ONLY=false for arg in "$@"; do case $arg in --build) BUILD=true ;; --sync-only) SYNC_ONLY=true ;; esac done if [ "$BUILD" = true ]; then echo "Building standalone..." python build.py fi echo "Syncing gen/standalone/ to $SERVER:$REMOTE_DIR..." rsync -avz --delete \ --exclude='__pycache__' \ --exclude='.venv' \ --exclude='*.pyc' \ --exclude='.env' \ --filter=':- .gitignore' \ gen/standalone/ "$SERVER:$REMOTE_DIR/" if [ "$SYNC_ONLY" = true ]; then echo "Sync complete (restart skipped)" exit 0 fi echo "Restarting soleprint on server..." # The compose file runs the container as ${UID:-1000}:${GID:-1000} and bind-mounts # the deployed tree at /app. Those have to be the ids that OWN the tree, and they # are not 1000 on every host — mcrn.ar's user is 1001. Without this the container # starts fine and then 500s on the first file it reads, which reads as an app bug # rather than a permissions one. # # `env` rather than a prefix assignment: UID is readonly in bash, so # `UID=$(id -u) docker ...` fails outright. ssh "$SERVER" "cd $REMOTE_DIR && env UID=\$(id -u) GID=\$(id -g) docker compose up -d --build" echo "Deploy complete"