Compare commits

...

28 Commits
main ... master

Author SHA1 Message Date
fc59ec3ca3 Solves weird permission issues in wp-content. 2025-06-22 20:19:26 +00:00
9cfdd8b1d8 Now fixes lines 2025-06-15 00:08:21 +00:00
26a44a752a Corrects lines 2025-06-15 00:06:56 +00:00
bac48588e4 Shuffle the salts! 2025-06-15 00:05:57 +00:00
712e68b2cf Made wp-config.php separate from git, so that it can be edited by users. 2025-06-14 23:44:06 +00:00
f53e751901 More wp-cli notes 2025-06-14 22:25:06 +00:00
5563b5a3b3 Introduces wp-cli 2025-06-14 22:13:17 +00:00
bad1d978cc Adds wordpress:cl in it's own container. 2025-06-14 21:57:39 +00:00
1dc2e1ceb6 Only extracts 1st Virtual Host 2025-06-11 17:00:00 +00:00
002dfea366 Added some improvements learned from CRWT upgrade. 2025-06-10 18:41:07 +00:00
48a64c674c Improvements 2025-06-09 18:20:14 +00:00
642aa23e54 More enlightenment 2025-06-09 16:39:05 +00:00
e66297136e Automates Build & Deploy 2025-06-09 16:34:25 +00:00
d58cd6e879 Can now make changes to default.conf without overwrite if changing project name. 2025-06-08 22:57:34 +00:00
4ace5fb035 Solves an issue of hardwiring user/password in wordpress for database. 2025-06-08 22:07:27 +00:00
075cfed0c5 Improves for 1st database initializing with proper env var, and corrects update-db. 2025-06-08 21:49:06 +00:00
da76a4f226 Minor fix 2025-06-08 20:29:44 +00:00
ce09981e26 This cleans up the update-db script, and doesn't require that the variables be declared. 2025-06-08 20:28:57 +00:00
297ae0b51e Removes unnecessary env variables 2025-06-08 19:40:44 +00:00
edacb41aa6 Removes the requirement to set WORDPRESS_DB_HOST in .env. 2025-06-08 19:33:52 +00:00
370d4fe771 Hopefully, corrects @bike 2025-06-08 18:21:34 +00:00
e261cc0805 It's bike at bikeshopi! 2025-06-08 18:19:13 +00:00
a8c2c448f6 Updates and fancier 2025-06-08 18:13:47 +00:00
b3c3c387f6 Resolves network issue with non-unique service names not playing well with the external letsencrypt network. 2025-06-08 17:53:29 +00:00
db9e08f943 Factoring in ARG change for Wordpress versions. 2025-06-05 18:54:55 +00:00
f13ed239e7 Updated to work with the mariadb command, rather than mysql command 2025-06-05 18:36:46 +00:00
2c5d0b01b9 Adds dynamic ARG for Dockerfile FROM 2025-06-05 18:36:08 +00:00
e98d4189de Added some optional instructions. 2025-06-05 18:35:14 +00:00
10 changed files with 301 additions and 79 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
.env .env
docker-compose.yml
default.conf
wp-config.php

View File

@ -1,7 +1,8 @@
# Wordpress - make a copy of wp-includes to compare with existing volumes # Wordpress - make a copy of wp-includes to compare with existing volumes
# 'docker-compose exec wordpress bash -c 'cd /var/www/html/wp-includes && grep wp_version version.php' # 'docker-compose exec wordpress bash -c 'cd /var/www/html/wp-includes && grep wp_version version.php'
FROM wordpress:6-fpm ARG WORDPRESS_VERSION=user-defined
FROM wordpress:${WORDPRESS_VERSION}
# ancient debian # ancient debian
#RUN apt update && apt -y install vim less #RUN apt update && apt -y install vim less

174
README.md
View File

@ -1,31 +1,30 @@
# ComposePress # ComposePress
A Docker-based toolkit that streamlines WordPress upgrades using official images. Provides pre-configured docker-compose files, Dockerfiles, and standardized procedures to make WordPress maintenance more predictable and reliable. ComposePress is a **Docker-based toolkit** designed to streamline WordPress upgrades using official images. It provides **pre-configured Docker Compose files**, Dockerfiles, and standardized procedures to make WordPress maintenance more predictable and reliable.
## Project Configuration ---
### Project Name ## 🚀 Project Configuration
This project requires a project name, which should be defined in an `.env` file:
### **Project Name & WordPress Version**
Define a **unique project name** and **WordPress version** in the `.env` file:
```bash ```bash
COMPOSE_PROJECT_NAME=test COMPOSE_PROJECT_NAME=test
WORDPRESS_VERSION=6-fpm
``` ```
### Database Host Configuration ---
To avoid conflicts, use the following format for the database host:
```bash
WORDPRESS_DB_HOST=${COMPOSE_PROJECT_NAME}-database-1:3306
```
## Environment Variables ## 🛠 Environment Variables
### Docker Images ### **Docker Images**
```bash ```bash
# Web and Database Images # Web & Database Images
IMAGE_WEB=test_web_staging IMAGE_WEB=test_web_staging
IMAGE_DATABASE=mariadb:11.5 IMAGE_DATABASE=mariadb:11.5
``` ```
### Let's Encrypt Configuration ### **Let's Encrypt Configuration**
```bash ```bash
VIRTUAL_HOST=test.test.org VIRTUAL_HOST=test.test.org
LETSENCRYPT_HOST=test.test.org LETSENCRYPT_HOST=test.test.org
@ -33,73 +32,164 @@ LETSENCRYPT_EMAIL=test@test.com
LETSENCRYPT_TEST=true LETSENCRYPT_TEST=true
``` ```
### Database Configuration ### **Database Configuration**
```bash ```bash
WORDPRESS_DB_HOST=${COMPOSE_PROJECT_NAME}-database-1:3306 WORDPRESS_DB_PASSWORD=wordpress # Used for MYSQL_PASSWORD AND MYSQL_ROOT_PASSWORD
WORDPRESS_DB_PASSWORD=wordpress
MYSQL_ROOT_PASSWORD=wordpress
MYSQL_DATABASE=wordpress MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress MYSQL_USER=wordpress
MYSQL_PASSWORD=wordpress TABLE_PREFIX=test # optional
``` ```
### Volume Configuration ### **Volume Configuration**
```bash ```bash
# External Volumes # External Volumes (Persist Data)
DB_VOLUME=test_db_staging DB_VOLUME=test_db_staging
CONTENT_VOLUME=test_content_staging CONTENT_VOLUME=test_content_staging
# Recreated Volumes # Recreated Volumes (Rebuild On Setup)
HTML_VOLUME=test_html_staging HTML_VOLUME=test_html_staging
``` ```
## Usage ---
### Upgrade Process ## 📂 Configuration Files
1. Stop the current containers and remove volumes: Three important configuration files are available in the project directory:
```bash ```bash
docker compose down -v Nginx (after editing, perform a restart):
./default.conf # generate-compose-nginx.sh respects user added changes
./nginx.conf # Manually customizable configuration
Wordress:
./wp-config.php # generated once by generate-compose-nginx.sh and respects user added changes
``` ```
2. Update WordPress version: ---
- Modify version in `Dockerfile.wordpress_fpm`
- Update `IMAGE_WEB` in `.env` file
3. Build and test the new environment: ## 🚀 Usage
### **Initialize a Project with a Unique `COMPOSE_PROJECT_NAME`; expects one word**
Run the following script to generate the required files:
```bash ```bash
# Build initial configuration ./generate-compose-nginx.sh
```
---
## 🔄 Upgrade Process
### 🚀 **Automated Upgrade (Recommended)**
If you want a **fully automated** upgrade, use the `wp-rocket-launch.sh` script:
```bash
./wp-rocket-launch.sh
```
✅ Automatically cleans up existing containers and volumes
✅ Builds the custom WordPress image
✅ Deploys the new version with minimal manual intervention
✅ Copies new installation files to production and correct permissions
✅ Wordpress salt keys are shuffled
Alternatively, follow the manual upgrade process below.
### 🚀 **Manual Upgrade (Expert Mode)**
### **1⃣ Stop Containers & Clean Up**
```bash
docker compose down -v
# Optional: Remove external database & content volume (DANGER: Only do this if you have backups)
grep -E 'DB_VOLUME|CONTENT_VOLUME' .env | cut -d '=' -f2 | xargs -I {} sh -c 'docker volume rm {} 2>/dev/null; docker volume create {}'
# Optional: Remove WordPress Image
docker rmi $(grep IMAGE_WEB .env | cut -d '=' -f2)
```
### **2⃣ Update WordPress Version**
Modify the version in .env:
```bash
WORDPRESS_VERSION=7-fpm
```
### **3⃣ Build & Deploy**
```bash
# Build custom WordPress image
docker compose -f docker-compose.first.yml build docker compose -f docker-compose.first.yml build
# Test the build # Install or upgrade WordPress volume from custom image
docker compose -f docker-compose.first.yml up -d docker compose -f docker-compose.first.yml up -d
# Stop test environment # Stop WordPress container (but keep HTML volume)
docker compose -f docker-compose.first.yml down docker compose -f docker-compose.first.yml down
# Start production environment # Start production environment
docker compose up -d docker compose up -d
``` ```
4. Migrate content:
### **4⃣ Migrate Content (Themes, Plugins)**
```bash ```bash
# In the wordpress service, copy new content to production # Copy new content to production
cp -a wp-content-new/* wp-content/ cp -a wp-content-new/* wp-content/
# Verify permissions on wp-content directory # Verify permissions on the wp-content directory
chmod -R [appropriate-permissions] wp-content/ chmod -R [appropriate-permissions] wp-content/
``` ```
5. Optional: Update database if needed: ### **5⃣ Optional: Database Updates for web address change**
```bash ```bash
./update-db ./update-db
or
docker compose exec wpcli_${COMPOSE_PROJECT_NAME} wp option update siteurl "https://mynewwebsite.com"
docker compose exec wpcli_${COMPOSE_PROJECT_NAME} wp option update home "https://mynewwebsite.com"
``` ```
## Requirements ---
Docker ## Tricks of the Trade
## Contributing Cookie issues prevent login? Add to beginning of wp-config.php.
@bike ```bash
ob_start();
```
## License Change to a different template. Perhaps the current one has broken the site?
[GNU GENERAL PUBLIC LICENSE](LICENSE) ```sql
UPDATE wp_options SET option_value = 'twentytwentyfive' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'twentytwentyfive' WHERE option_name = 'stylesheet';
or
docker compose exec wpcli_${COMPOSE_PROJECT_NAME} wp theme activate twentytwentyfive
```
Disable all plugins
```sql
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
or
docker compose exec wpcli_${COMPOSE_PROJECT_NAME} wp plugin deactivate --all
```
---
## 📌 Requirements
- Docker
---
## 🤝 Contributing
For contributions, reach out to @bike .
---
## 📜 License
GNU GENERAL PUBLIC LICENSE

View File

@ -5,7 +5,7 @@ server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
server_name wordpress; server_name wordpress_${COMPOSE_PROJECT_NAME};
root /var/www/html; root /var/www/html;
index index.php; index index.php;
@ -24,11 +24,11 @@ server {
} }
# pass the PHP scripts to FastCGI server listening on wordpress2:9000 # pass the PHP scripts to FastCGI server listening on wordpress:9000
# #
location ~ \.php$ { location ~ \.php$ {
#fastcgi_split_path_info ^(.+\.php)(/.+)$; #fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000; fastcgi_pass wordpress_${COMPOSE_PROJECT_NAME}:9000;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;

View File

@ -7,6 +7,8 @@ services:
build: build:
context: . context: .
dockerfile: Dockerfile.wordpress_fpm dockerfile: Dockerfile.wordpress_fpm
args:
WORDPRESS_VERSION: ${WORDPRESS_VERSION}
image: ${IMAGE_WEB:-web} image: ${IMAGE_WEB:-web}
volumes: volumes:
- html:/var/www/html - html:/var/www/html
@ -24,8 +26,9 @@ services:
max-file: "3" max-file: "3"
restart: always restart: always
networks: networks:
- custom_network
- letsencrypt - letsencrypt
- default
volumes: volumes:
html: html:
@ -34,3 +37,5 @@ volumes:
networks: networks:
letsencrypt: letsencrypt:
external: true external: true
custom_network:
name: ${COMPOSE_PROJECT_NAME}_network # Uses project-specific name

View File

@ -18,15 +18,17 @@
services: services:
database: database_${SERVICE_SUFFIX}:
image: ${IMAGE_DATABASE:-database} image: ${IMAGE_DATABASE:-database}
container_name: ${COMPOSE_PROJECT_NAME}_database
volumes: volumes:
- db:/var/lib/mysql - db:/var/lib/mysql
environment: environment:
- MYSQL_PASSWORD=${WORDPRESS_DB_PASSWORD:-fake}
- MYSQL_ROOT_PASSWORD=${WORDPRESS_DB_PASSWORD:-fake}
- MYSQL_DATABASE=${MYSQL_DATABASE:-wordpress} - MYSQL_DATABASE=${MYSQL_DATABASE:-wordpress}
- MYSQL_USER=${MYSQL_USER:-wordpress} - MYSQL_USER=${MYSQL_USER:-wordpress}
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-fake} - MARIADB_AUTO_UPGRADE=1
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-fake}
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
@ -34,20 +36,21 @@ services:
max-file: "3" max-file: "3"
restart: always restart: always
networks: networks:
- letsencrypt - custom_network
wordpress: wordpress_${SERVICE_SUFFIX}:
# build:
# context: .
# dockerfile: Dockerfile.wordpress_fpm
image: ${IMAGE_WEB:-wordpress} image: ${IMAGE_WEB:-wordpress}
container_name: ${COMPOSE_PROJECT_NAME}_wordpress
volumes: volumes:
- html:/var/www/html - html:/var/www/html
- content:/var/www/html/wp-content - content:/var/www/html/wp-content
- ./wp-config.php:/var/www/html/wp-config.php - ./wp-config.php:/var/www/html/wp-config.php
environment: environment:
- WORDPRESS_DB_HOST=${WORDPRESS_DB_HOST:-database:3306} - WORDPRESS_DB_HOST=database_${COMPOSE_PROJECT_NAME}:3306
- WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD:-fake} - WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD:-fake}
- MYSQL_DATABASE=${MYSQL_DATABASE:-wordpress}
- MYSQL_USER=${MYSQL_USER:-wordpress}
- TABLE_PREFIX=${TABLE_PREFIX:-wp_}
- VIRTUAL_HOST=${VIRTUAL_HOST:-wordpress} - VIRTUAL_HOST=${VIRTUAL_HOST:-wordpress}
- LETSENCRYPT_HOST=${LETSENCRYPT_HOST:-wordpress} - LETSENCRYPT_HOST=${LETSENCRYPT_HOST:-wordpress}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-me} - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-me}
@ -61,19 +64,21 @@ services:
command: > command: >
bash -c "chown -R www-data:www-data /var/www/html/wp-content && php-fpm" bash -c "chown -R www-data:www-data /var/www/html/wp-content && php-fpm"
networks: networks:
- custom_network
- letsencrypt - letsencrypt
- default
# nginx:latest and/or can be customized # nginx:latest and/or can be customized
web: web_${SERVICE_SUFFIX}:
# build: # build:
# context: . # context: .
# dockerfile: Dockerfile.nginx # dockerfile: Dockerfile.nginx
image: nginx:latest image: nginx:latest
container_name: ${COMPOSE_PROJECT_NAME}_web
restart: always restart: always
volumes: volumes:
- html:/var/www/html/ - html:/var/www/html/
- content:/var/www/html/wp-content - content:/var/www/html/wp-content
- ./wp-config.php:/var/www/html/wp-config.php
- ./default.conf:/etc/nginx/conf.d/default.conf - ./default.conf:/etc/nginx/conf.d/default.conf
- ./nginx.conf:/etc/nginx/nginx.conf - ./nginx.conf:/etc/nginx/nginx.conf
environment: environment:
@ -82,8 +87,29 @@ services:
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-me} - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL:-me}
- LETSENCRYPT_TEST=${LETSENCRYPT_TEST:-true} - LETSENCRYPT_TEST=${LETSENCRYPT_TEST:-true}
networks: networks:
- custom_network
- letsencrypt - letsencrypt
- default
wpcli_${SERVICE_SUFFIX}:
image: wordpress:cli
container_name: ${COMPOSE_PROJECT_NAME}_wpcli
depends_on:
- database_${SERVICE_SUFFIX}
- wordpress_${SERVICE_SUFFIX}
command: tail -f /dev/null # Keeps the container running for CLI commands
volumes:
- html:/var/www/html
- content:/var/www/html/wp-content
- ./wp-config.php:/var/www/html/wp-config.php
user: "33:${HOST_GID}"
environment:
- WORDPRESS_DB_HOST=database_${COMPOSE_PROJECT_NAME}:3306
- WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD:-fake}
- MYSQL_DATABASE=${MYSQL_DATABASE:-wordpress}
- MYSQL_USER=${MYSQL_USER:-wordpress}
- TABLE_PREFIX=${TABLE_PREFIX:-wp_}
networks:
- custom_network
# No variable substition for volumes in this version # No variable substition for volumes in this version
volumes: volumes:
@ -99,5 +125,5 @@ volumes:
networks: networks:
letsencrypt: letsencrypt:
external: true external: true
# default: custom_network:
# name: ${COMPOSE_PROJECT_NAME}_default name: ${COMPOSE_PROJECT_NAME}_network # Uses project-specific name

41
generate-compose-nginx.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Docker service names are designed to be static, not dynamic,
# primarily due to the need for predictable and consistent communication
# between services within a Docker Compose environment. However, since an
# external letsencrypt network is utilized, conflicts occur if the service
# name is not unique to the project. This script resolves that issue by
# generating a docker-compose.yml file with unique service names, which is
# the COMPOSE_PROJECT_NAME
# Load variables from .env file
if [ -f .env ]; then
source .env
fi
export SERVICE_SUFFIX=${COMPOSE_PROJECT_NAME:-main}
export COMPOSE_PROJECT_NAME
export HOST_UID=$(id -u)
export HOST_GID=$(id -g)
envsubst < docker-compose.template.yml > docker-compose.yml
if [ ! -f wp-config.conf ]; then
cp wp-config.template.php wp-config.php
chmod 0664 wp-config.php
fi
# Define the new value for the database host
export new_wp="wordpress_${COMPOSE_PROJECT_NAME}"
# If default.conf doesn't exist, create it from the template (using envsubst restricted to COMPOSE_PROJECT_NAME)
if [ ! -f default.conf ]; then
echo "default.conf not found, creating from default.template.conf..."
envsubst '${COMPOSE_PROJECT_NAME}' < default.template.conf > default.conf
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.
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

View File

@ -1,14 +1,19 @@
#!/bin/bash #!/bin/bash
source ".env" set -o allexport
source .env
set +o allexport
website="https://$VIRTUAL_HOST" FIRST_VIRTUAL_HOST=$(echo "$VIRTUAL_HOST" | cut -d',' -f1)
command="docker-compose exec database mysql"
website="https://$FIRST_VIRTUAL_HOST"
DATABASE_SERVICE="database_${COMPOSE_PROJECT_NAME}"
command="docker compose exec $DATABASE_SERVICE mariadb"
echo $website echo $website
$command -u $MYSQL_USER $MYSQL_DATABASE -p"$WORDPRESS_DB_PASSWORD" -e "UPDATE cf_options SET option_value='$website' WHERE option_name='home';" $command -u $MYSQL_USER $MYSQL_DATABASE -p"$WORDPRESS_DB_PASSWORD" -e "UPDATE ${TABLE_PREFIX}options SET option_value='$website' WHERE option_name='home';"
$command -u $MYSQL_USER $MYSQL_DATABASE -p"$WORDPRESS_DB_PASSWORD" -e "UPDATE cf_options SET option_value='$website' WHERE option_name='siteurl';" $command -u $MYSQL_USER $MYSQL_DATABASE -p"$WORDPRESS_DB_PASSWORD" -e "UPDATE ${TABLE_PREFIX}options SET option_value='$website' WHERE option_name='siteurl';"
## Add ## Add
# /usr/bin/find /var/www/html/wp-content/uploads/ -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \; # /usr/bin/find /var/www/html/wp-content/uploads/ -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \;

View File

@ -20,13 +20,13 @@
// ** MySQL settings - You can get this info from your web host ** // // ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */ /** The name of the database for WordPress */
define('DB_NAME', 'wordpress'); define('DB_NAME', getenv('MYSQL_DATABASE'));
/** MySQL database username */ /** MySQL database username */
define('DB_USER', 'root'); define('DB_USER', getenv('MYSQL_USER'));
/** MySQL database password */ /** MySQL database password */
define('DB_PASSWORD', 'wordpress'); define('DB_PASSWORD', getenv('WORDPRESS_DB_PASSWORD'));
/** MySQL hostname */ /** MySQL hostname */
define('DB_HOST', getenv('WORDPRESS_DB_HOST')); define('DB_HOST', getenv('WORDPRESS_DB_HOST'));
@ -63,7 +63,7 @@ define('NONCE_SALT', '!M@7=}Gsx@4MVX|][e<N--f@BvkG_8,z5*8.G#lPr<Wrl0^0}hEV
* You can have multiple installations in one database if you give each * You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please! * a unique prefix. Only numbers, letters, and underscores please!
*/ */
$table_prefix = 'cf_'; $table_prefix = getenv('TABLE_PREFIX') ?: 'wp_';
/** /**
* For developers: WordPress debugging mode. * For developers: WordPress debugging mode.

51
wp-rocket-launch.sh Executable file
View File

@ -0,0 +1,51 @@
#!/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 and correct permissions..."
docker compose exec wordpress_${COMPOSE_PROJECT_NAME} bash -c "cp -a /var/www/html/wp-content-new/* /var/www/html/wp-content/"
docker compose exec wordpress_${COMPOSE_PROJECT_NAME} bash -c "/usr/bin/find /var/www/html/wp-content -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \;"
echo "✅ WordPress content successfully copied!"
# Step 7: Shuffle salts
echo "📂 Shuffle the salt keys...."
docker compose exec wpcli_${COMPOSE_PROJECT_NAME} wp config shuffle-salts
echo "✅ Wordpress salt keys sucessfully shuffled!"