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)..."
|
echo "🌐 Synchronizing with production server ($SERVER_IP)..."
|
||||||
|
|
||||||
ssh $SERVER_USER@$SERVER_IP << EOF
|
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
|
git config --global --add safe.directory $PROJECT_DIR
|
||||||
|
|
||||||
|
cd $PROJECT_DIR
|
||||||
|
|
||||||
if [ ! -d ".git" ]; then
|
if [ ! -d ".git" ]; then
|
||||||
echo "🌑 Initializing production repository (Force setup in non-empty dir)..."
|
echo "🌑 Initializing production repository (Force setup)..."
|
||||||
git init
|
git init
|
||||||
git config --global --add safe.directory $PROJECT_DIR
|
git config --global --add safe.directory $PROJECT_DIR
|
||||||
git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git
|
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
|
git reset --hard origin/main
|
||||||
else
|
else
|
||||||
echo "⬇️ Pulling latest changes from Git..."
|
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 || true
|
||||||
git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git 2>/dev/null
|
git fetch --all
|
||||||
git pull origin main
|
git reset --hard origin/main
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "docker-compose.yml" ]; then
|
if [ -f "docker-compose.yml" ]; then
|
||||||
echo "🏗️ Rebuilding production containers (Docker Compose)..."
|
echo "🏗️ Rebuilding production containers using \$DOCKER_CMD..."
|
||||||
docker compose up -d --build
|
\$DOCKER_CMD up -d --build
|
||||||
else
|
else
|
||||||
echo "❌ Error: docker-compose.yml not found on server!"
|
echo "❌ Error: docker-compose.yml not found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user