Hardened deployment with Docker fix
This commit is contained in:
@@ -28,11 +28,22 @@ PROJECT_DIR="/home/intaleqapp-musadeq/htdocs/musadeq.intaleqapp.com"
|
||||
echo "🌐 Synchronizing with production server ($SERVER_IP)..."
|
||||
|
||||
ssh $SERVER_USER@$SERVER_IP << EOF
|
||||
cd $PROJECT_DIR
|
||||
set -e
|
||||
|
||||
# Check for Docker Compose command
|
||||
if docker compose version > /dev/null 2>&1; then
|
||||
DOCKER_CMD="docker compose"
|
||||
else
|
||||
DOCKER_CMD="docker-compose"
|
||||
fi
|
||||
|
||||
echo "🔐 Configuring Git safe directory..."
|
||||
git config --global --add safe.directory $PROJECT_DIR
|
||||
|
||||
cd $PROJECT_DIR
|
||||
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "🌑 Initializing production repository (Force setup in non-empty dir)..."
|
||||
echo "🌑 Initializing production repository (Force setup)..."
|
||||
git init
|
||||
git config --global --add safe.directory $PROJECT_DIR
|
||||
git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git
|
||||
@@ -40,16 +51,16 @@ ssh $SERVER_USER@$SERVER_IP << EOF
|
||||
git reset --hard origin/main
|
||||
else
|
||||
echo "⬇️ Pulling latest changes from Git..."
|
||||
# In case remote was lost or ownership changed
|
||||
git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git 2>/dev/null
|
||||
git pull origin main
|
||||
git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git 2>/dev/null || true
|
||||
git fetch --all
|
||||
git reset --hard origin/main
|
||||
fi
|
||||
|
||||
if [ -f "docker-compose.yml" ]; then
|
||||
echo "🏗️ Rebuilding production containers (Docker Compose)..."
|
||||
docker compose up -d --build
|
||||
echo "🏗️ Rebuilding production containers using \$DOCKER_CMD..."
|
||||
\$DOCKER_CMD up -d --build
|
||||
else
|
||||
echo "❌ Error: docker-compose.yml not found on server!"
|
||||
echo "❌ Error: docker-compose.yml not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user