diff --git a/README.md b/README.md index 325fa75..8d583b8 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,22 @@ # Einrichten ``` echo "MYSQL_ROOT_PASSWORD=$( openssl rand -hex 16 )" > .env -MYSQL_DATABASE=wordpress >> .env -MYSQL_USER=wordpress >> .env +echo "MYSQL_DATABASE=wordpress" >> .env +echo "MYSQL_USER=wordpress" >> .env echo "MYSQL_PASSWORD=$( openssl rand -hex 16 )" >> .env +echo "WP_PORT=8080" >> .env +echo "STATIC_PORT=8081" >> .env ``` +## Redis Object Cache + +After first `docker compose up`, install the **Redis Object Cache** plugin in WP Admin: +1. Plugins → Add New → search "Redis Object Cache" (by Till Krüss) +2. Install & Activate +3. Settings → Redis → "Enable Object Cache" + +The `wp-config.php` already has the `WP_REDIS_HOST` and `WP_REDIS_PORT` constants set. + ## Cron Backup script in Cron einbinden nicht vergessen \ No newline at end of file diff --git a/compose.yml b/compose.yml index af4869a..bdc35e2 100644 --- a/compose.yml +++ b/compose.yml @@ -11,24 +11,75 @@ services: - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} + networks: + - backend + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 30s + timeout: 10s + retries: 5 + start_period: 30s + + redis: + image: redis:7-alpine + restart: unless-stopped + command: redis-server --maxmemory 128mb --maxmemory-policy allkeys-lru + volumes: + - redis_data:/data + networks: + - backend + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 30s + timeout: 5s + retries: 3 + wordpress: image: wordpress:latest + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy volumes: - ./wp:/var/www/html - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini + - ./opcache.ini:/usr/local/etc/php/conf.d/opcache.ini - ./static:/export ports: - - 8080:80 + - ${WP_PORT:-8080}:80 restart: unless-stopped environment: - WORDPRESS_DB_HOST=db - WORDPRESS_DB_USER=${MYSQL_USER} - WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD} - WORDPRESS_DB_NAME=${MYSQL_DATABASE} + - WORDPRESS_CONFIG_EXTRA= + define('WP_REDIS_HOST', 'redis'); + define('WP_REDIS_PORT', 6379); + define('WP_REDIS_TIMEOUT', 1); + define('WP_REDIS_READ_TIMEOUT', 1); + define('DISALLOW_FILE_EDIT', true); + define('WP_AUTO_UPDATE_CORE', 'minor'); + define('AUTOMATIC_UPDATER_DISABLED', false); + networks: + - frontend + - backend + static: - image: caddy:latest - restart: unless-stopped - volumes: - - ./static:/usr/share/caddy - ports: - - 8081:80 \ No newline at end of file + image: caddy:latest + restart: unless-stopped + volumes: + - ./static:/usr/share/caddy + ports: + - ${STATIC_PORT:-8081}:80 + networks: + - frontend + +networks: + frontend: + backend: + internal: true + +volumes: + redis_data: \ No newline at end of file diff --git a/example.env b/example.env index 0794838..926ba54 100644 --- a/example.env +++ b/example.env @@ -1,4 +1,6 @@ MYSQL_ROOT_PASSWORD=$( openssl rand -hex 16 ) MYSQL_DATABASE=wordpress MYSQL_USER=wordpress -MYSQL_PASSWORD=$( openssl rand -hex 16 ) \ No newline at end of file +MYSQL_PASSWORD=$( openssl rand -hex 16 ) +WP_PORT=8080 +STATIC_PORT=8081 \ No newline at end of file diff --git a/opcache.ini b/opcache.ini new file mode 100644 index 0000000..ccecb43 --- /dev/null +++ b/opcache.ini @@ -0,0 +1,8 @@ +; OPcache – caches compiled PHP for major speed gains +opcache.enable=1 +opcache.memory_consumption=128 +opcache.interned_strings_buffer=16 +opcache.max_accelerated_files=10000 +opcache.revalidate_freq=60 +opcache.fast_shutdown=1 +opcache.enable_cli=0