mirror of
https://git.victorphan.net/basketballcantho/ten-project.git
synced 2026-08-05 10:43:11 +07:00
hoàn thành docker compose giai đoạn 1
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#!/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:-3000}"
|
||||
docker compose ps
|
||||
Reference in New Issue
Block a user