Automates Build & Deploy
This commit is contained in:
parent
d58cd6e879
commit
e66297136e
@ -103,8 +103,12 @@ docker compose -f docker-compose.first.yml down
|
||||
|
||||
# Start production environment
|
||||
docker compose up -d
|
||||
|
||||
# Or just run
|
||||
./wp-rocket-launch.sh #also copies new content to production.
|
||||
```
|
||||
|
||||
|
||||
### **4️⃣ Migrate Content (Themes, Plugins)**
|
||||
```bash
|
||||
# Copy new content to production
|
||||
|
@ -29,7 +29,6 @@ fi
|
||||
# Check if the existing default.conf contains a database hostname matching the pattern (it may or may not contain the env variable placeholder)
|
||||
if grep -qE "\bwordpress_\w+(?::\d+)?\b" default.conf; then
|
||||
# Update in-place only the portion that matches the database host pattern.
|
||||
# sed -i "s/\bwordpress_\w+(?::\d+)?\b/${new_wp}/g" default.conf
|
||||
perl -pi -e 's/\bwordpress_\w+(?::(\d+))?\b/$ENV{"new_wp"} . (defined($1) ? ":$1" : "")/eg' default.conf
|
||||
echo "default.conf updated with COMPOSE_PROJECT_NAME='${COMPOSE_PROJECT_NAME}'."
|
||||
fi
|
||||
|
45
wp-rocket-launch.sh
Executable file
45
wp-rocket-launch.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define environment variables
|
||||
COMPOSE_FILE="docker-compose.first.yml"
|
||||
|
||||
echo "🚀 Starting WordPress Deployment Process..."
|
||||
|
||||
# Step 0: **Reset Environment** - Stop and remove volumes
|
||||
echo "🧹 Cleaning up existing containers and volumes..."
|
||||
docker compose down -v
|
||||
|
||||
# Step 1: Build custom WordPress image
|
||||
echo "🔧 Building custom WordPress image..."
|
||||
docker compose -f "$COMPOSE_FILE" build
|
||||
|
||||
# Step 2: Install or upgrade WordPress volume
|
||||
echo "📦 Installing or upgrading WordPress volume..."
|
||||
docker compose -f "$COMPOSE_FILE" up -d
|
||||
|
||||
# Step 3: Stop WordPress container (keep HTML volume)
|
||||
echo "⏹️ Stopping WordPress container (keeping data)..."
|
||||
docker compose -f "$COMPOSE_FILE" down
|
||||
|
||||
# Step 4: Start production environment
|
||||
echo "🚀 Launching production environment..."
|
||||
docker compose up -d
|
||||
|
||||
# Step 5: Source .env and extract the first VIRTUAL_HOST address
|
||||
if [ -f .env ]; then
|
||||
set -o allexport
|
||||
source .env
|
||||
set +o allexport
|
||||
|
||||
# Extract only the first address from VIRTUAL_HOST
|
||||
FIRST_VIRTUAL_HOST=$(echo "$VIRTUAL_HOST" | cut -d',' -f1)
|
||||
|
||||
echo "✅ WordPress deployment complete! Site is live at: https://${FIRST_VIRTUAL_HOST}"
|
||||
else
|
||||
echo "⚠️ .env file not found, VIRTUAL_HOST could not be displayed."
|
||||
fi
|
||||
|
||||
# Step 6: Copy new WordPress content after deployment
|
||||
echo "📂 Copying new WordPress content to wp-content..."
|
||||
docker compose exec wordpress_${COMPOSE_PROJECT_NAME} bash -c "cp -a /var/www/html/wp-content-new/* /var/www/html/wp-content/"
|
||||
echo "✅ WordPress content successfully copied!"
|
Loading…
x
Reference in New Issue
Block a user