GitHunt
KE

keshon/modx-docker-traefik

Docker environment setup for Nginx + PHP8

๐ŸŒ MODx CMS with Docker & Traefik ๐Ÿš€

This repository sets up a MODx Content Management System environment using Docker, with Traefik as the reverse proxy for seamless HTTPS routing and management. This setup also includes PHPMyAdmin for database management.

๐Ÿ“‚ Project Structure

modx-docker-traefik/
โ”ฃ db/                    # Database data directory
โ”ฃ db_backup/             # Database backups
โ”ฃ nginx/                 
โ”ƒ โ”— site.conf            # NGINX server configuration
โ”ฃ php/                   
โ”ƒ โ”— dockerfile           # PHP Dockerfile
โ”ฃ www/                   # Web root directory (place MODx files here)
โ”ฃ .env                   # Environment variables
โ”ฃ db_backup.sh           # Backup script for database
โ”ฃ db_dump.sh             # Database dump script (being called from db_backup.sh)
โ”ฃ docker-compose.yml     # Docker Compose for build & deploy
โ”ฃ fix_www_perm.sh        # Script to set correct permissions for www directory
โ”— README.md              # This readme file

โš™๏ธ Prerequisites

Ensure you have the following installed on your machine:

  • Docker (recent version can read docker-compose on its own) ๐Ÿณ
  • Traefik (installed separately for external proxy network) ๐ŸŒ

๐Ÿš€ Getting Started

1. Clone the Repository

git clone https://github.com/keshon/modx-docker-traefik.git
cd modx-docker-traefik

2. Configure Environment Variables

Set up the .env file for your MODx environment:

ALIAS=examplealias
HOST=example.com
PHPMYADMIN_DOMAIN=phpmyadmin.example.com
MYSQL_ROOT_PASSWORD=makeupyourrootpassword
DB_NAME=dbnameitself
DB_USER=dbusername
DB_PASSWORD=dbpassword

3. Set Up docker-compose.yml

The docker-compose.yml file is configured for NGINX, PHP, MySQL, and PHPMyAdmin services:

  • NGINX: Handles web requests and redirects with Traefik.
  • PHP: The PHP environment for MODx.
  • MySQL: Database service.
  • PHPMyAdmin: Web-based MySQL admin tool.

4. Build and Launch the Stack

Run the following command to build and start the containers:

docker compose up -d

๐Ÿ“ Note: Ensure Traefik is properly configured to use the proxy network.

5. Access MODx and PHPMyAdmin

๐Ÿ—„๏ธ Database Management

Backup the Database

Run the db_backup.sh script to back up the MySQL database.

./db_backup.sh

The backup will be stored as an archive in the db_backup/ folder with a timestamp.

๐Ÿ› ๏ธ Fix Permissions

Use fix_www_perm.sh to set proper permissions for the www/ directory:

./fix_www_perm.sh

This ensures files are owned by www-data with proper read/write permissions.

โš™๏ธ Configurations

NGINX Configuration

The NGINX configuration is in nginx/site.conf:

PHP Configuration

The PHP configuration (php/dockerfile) includes:

  • Essential PHP extensions for MODx.
  • Custom settings for file uploads, memory limits, and max execution time.
  • By default php 8 is used but you can change it to 7 if needed.

๐Ÿ“ Additional Notes

  • Traefik Configuration: Ensure your Traefik setup has a proxy network accessible to this stack.
  • Volume Persistence: Data for MySQL is stored in db/.

๐Ÿ“ License

This project is licensed under the MIT License. See the LICENSE file for details.

keshon/modx-docker-traefik | GitHunt