Files
StageAI/deploy.sh
CTO 4e74e4b5c9
All checks were successful
Deploy to VPS / deploy (push) Successful in 35s
fix: pass git commit hash as Docker build arg so footer shows correctly
git is not available inside the node:20-alpine Docker image, so
git rev-parse in next.config.ts falls back to 'dev'. Now the commit
hash is passed as a COMMIT_HASH build arg from the host where git
is available, ensuring the footer displays the real commit hash.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 21:06:04 +00:00

76 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# StageAI Deployment Script
# Pulls latest code from Gitea and redeploys via Docker Compose
#
# Usage (on VPS):
# ./deploy.sh # Pull & redeploy
# ./deploy.sh --build-only # Pull & rebuild without restarting
APP_DIR="/home/remmer/StageAI"
PROJECT_NAME="stageai"
REPO_URL="https://mgit.msbls.de/Remmer/StageAI.git"
BRANCH="master"
BUILD_ONLY=false
if [[ "${1:-}" == "--build-only" ]]; then
BUILD_ONLY=true
fi
echo "=== StageAI Deployment ==="
echo "Directory: $APP_DIR"
echo "Branch: $BRANCH"
echo ""
# Navigate to app directory
if [[ ! -d "$APP_DIR" ]]; then
echo "App directory not found. Cloning repo..."
git clone "$REPO_URL" "$APP_DIR"
fi
cd "$APP_DIR"
# Pull latest changes
echo "Pulling latest changes..."
git fetch origin "$BRANCH"
git reset --hard "origin/$BRANCH"
echo "Updated to: $(git log --oneline -1)"
# Rebuild containers
export COMMIT_HASH=$(git rev-parse --short HEAD)
echo ""
echo "Rebuilding containers (commit: $COMMIT_HASH)..."
docker compose -p "$PROJECT_NAME" build --no-cache app
if [[ "$BUILD_ONLY" == true ]]; then
echo ""
echo "Build complete (--build-only mode, skipping restart)."
exit 0
fi
# Restart app container (keep postgres and meilisearch running)
echo ""
echo "Restarting app container..."
docker compose -p "$PROJECT_NAME" up -d app
echo ""
echo "Waiting for app to start..."
sleep 5
# Health check
if curl -sf http://localhost:3002 > /dev/null 2>&1; then
echo "App is running at http://localhost:3002"
else
echo "Warning: App may not be ready yet. Check logs with:"
echo " docker compose -p $PROJECT_NAME logs -f app"
fi
echo ""
echo "=== Deployment complete ==="
echo ""
echo "Useful commands:"
echo " docker compose -p $PROJECT_NAME logs -f app # View app logs"
echo " docker compose -p $PROJECT_NAME ps # Container status"
echo " docker compose -p $PROJECT_NAME restart app # Restart app only"