Files
LMS/deploy.sh

43 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Pull LMS images from GHCR and start the stack on a new machine.
# Usage: ./deploy.sh
# Requires: .env file with BACKEND_IMAGE, FRONTEND_IMAGE, POSTGRES_PASSWORD, JWT_SECRET_KEY
set -e
cd "$(dirname "$0")"
if [ ! -f .env ]; then
echo "❌ .env not found. Copy .env.example → .env and fill in the values."
exit 1
fi
source .env
if [ -z "$POSTGRES_PASSWORD" ] || [ "$POSTGRES_PASSWORD" = "change_me_strong_password" ]; then
echo "❌ Set POSTGRES_PASSWORD in .env"
exit 1
fi
if [ -z "$JWT_SECRET_KEY" ] || [ "$JWT_SECRET_KEY" = "change_me_generate_with_secrets_token_hex_32" ]; then
echo "❌ Set JWT_SECRET_KEY in .env"
echo " Generate: python3 -c \"import secrets; print(secrets.token_hex(32))\""
exit 1
fi
# Login GHCR if token is provided
if [ -n "$GITHUB_TOKEN" ] && [ -n "$GITHUB_USER" ]; then
echo "🔐 Logging in to ghcr.io..."
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_USER" --password-stdin
fi
echo "📦 Pulling images from GHCR..."
docker compose pull
echo "🚀 Starting stack..."
docker compose up -d
echo ""
echo "✅ Running! Open http://localhost:${FRONTEND_PORT:-3011}"
docker compose ps