Updates and fancier

This commit is contained in:
Jonathan Rosenbaum 2025-06-08 18:13:47 +00:00
parent b3c3c387f6
commit a8c2c448f6

120
README.md
View File

@ -1,32 +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 and wordpress version, 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 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
@ -34,9 +32,9 @@ 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_HOST=database_${COMPOSE_PROJECT_NAME}:3306
WORDPRESS_DB_PASSWORD=wordpress WORDPRESS_DB_PASSWORD=wordpress
MYSQL_ROOT_PASSWORD=wordpress MYSQL_ROOT_PASSWORD=wordpress
MYSQL_DATABASE=wordpress MYSQL_DATABASE=wordpress
@ -44,83 +42,107 @@ MYSQL_USER=wordpress
MYSQL_PASSWORD=wordpress MYSQL_PASSWORD=wordpress
``` ```
### 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 ---
### Initialize project with unique COMPOSE_PROJECT_NAME ## 📂 Configuration Files
[./generate-compose-nginx.sh](generate-compose-nginx.sh) Two important Nginx configuration files are available in the project directory:
```bash
./default.conf # Automatically generated each time the script runs
./nginx.conf # Manually customizable configuration
```
### Upgrade Process ⚠️ **Warning:** `default.conf` is regenerated every time `generate-compose-nginx.sh` runs.
Make a backup before modifying if you plan to change the project name.
1. Stop the current containers and remove volumes: ---
## 🚀 Usage
### **Initialize a Project with a Unique `COMPOSE_PROJECT_NAME`**
Run the following script to generate the required files:
```bash
./generate-compose-nginx.sh
```
---
## 🔄 Upgrade Process
### **1⃣ Stop Containers & Clean Up**
```bash ```bash
docker compose down -v docker compose down -v
# Optional Steps for testing and development # Optional: Remove external database & content volume (DANGER: Only do this if you have backups)
# Remove external database and content volume (DANGER: only do this if you have backed up these two volumes)
grep -E 'DB_VOLUME|CONTENT_VOLUME' .env | cut -d '=' -f2 | xargs -I {} sh -c 'docker volume rm {} 2>/dev/null; docker volume create {}' grep -E 'DB_VOLUME|CONTENT_VOLUME' .env | cut -d '=' -f2 | xargs -I {} sh -c 'docker volume rm {} 2>/dev/null; docker volume create {}'
# Remove Wordpress Image # Optional: Remove WordPress Image
docker rmi $(grep IMAGE_WEB .env | cut -d '=' -f2) docker rmi $(grep IMAGE_WEB .env | cut -d '=' -f2)
``` ```
2. Update WordPress version: ### **2⃣ Update WordPress Version**
- Modify version in `Dockerfile.wordpress_fpm` Modify the version in .env:
- Update `IMAGE_WEB` in `.env` file
3. Build and reinstall the new environment:
```bash ```bash
# Build custom Wordpress image 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
# Install or Upgrade Wordpress /var/www/html volume (not external) from custom Wordpress image # 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 and remove Wordpress container, but keep html volume # 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 (e.g., themes, plugins) after a new installation or upgrade: ### **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**
```bash ```bash
(In the database container) # Inside the database container
apt-get update && \ apt-get update && \
apt-get install -y mariadb-client && \ apt-get install -y mariadb-client && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
(From the host) # From the host
./update-db ./update-db
``` ```
## Requirements ---
Docker
## Contributing ## 📌 Requirements
@bike - Docker
## License ---
[GNU GENERAL PUBLIC LICENSE](LICENSE)
## 🤝 Contributing
For contributions, reach out to [@bike](https://github.com/bike).
---
## 📜 License
GNU GENERAL PUBLIC LICENSE