ComposePress/README.md

188 lines
4.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ComposePress
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 & WordPress Version**
Define a **unique project name** and **WordPress version** in the `.env` file:
```bash
COMPOSE_PROJECT_NAME=test
WORDPRESS_VERSION=6-fpm
```
---
## 🛠 Environment Variables
### **Docker Images**
```bash
# Web & Database Images
IMAGE_WEB=test_web_staging
IMAGE_DATABASE=mariadb:11.5
```
### **Let's Encrypt Configuration**
```bash
VIRTUAL_HOST=test.test.org
LETSENCRYPT_HOST=test.test.org
LETSENCRYPT_EMAIL=test@test.com
LETSENCRYPT_TEST=true
```
### **Database Configuration**
```bash
WORDPRESS_DB_PASSWORD=wordpress # Used for MYSQL_PASSWORD AND MYSQL_ROOT_PASSWORD
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress
TABLE_PREFIX=test # optional
```
### **Volume Configuration**
```bash
# External Volumes (Persist Data)
DB_VOLUME=test_db_staging
CONTENT_VOLUME=test_content_staging
# Recreated Volumes (Rebuild On Setup)
HTML_VOLUME=test_html_staging
```
---
## 📂 Configuration Files
Two important Nginx configuration files are available in the project directory. After editing, perform a restart:
```bash
./default.conf # generate-compose-nginx.sh respects user added changes
./nginx.conf # Manually customizable configuration
```
---
## 🚀 Usage
### **Initialize a Project with a Unique `COMPOSE_PROJECT_NAME`; expects one word**
Run the following script to generate the required files:
```bash
./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
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
# Install or upgrade WordPress volume from custom image
docker compose -f docker-compose.first.yml up -d
# Stop WordPress container (but keep HTML volume)
docker compose -f docker-compose.first.yml down
# Start production environment
docker compose up -d
```
### **4⃣ Migrate Content (Themes, Plugins)**
```bash
# Copy new content to production
cp -a wp-content-new/* wp-content/
# Verify permissions on the wp-content directory
chmod -R [appropriate-permissions] wp-content/
```
### **5⃣ Optional: Database Updates for web address change**
```bash
./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"
```
---
## Tricks of the Trade
Cookie issues prevent login? Add to beginning of wp-config.php.
```bash
ob_start();
```
Change to a different template. Perhaps the current one has broken the site?
```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