From b9b83070883f53f88664a164acd509a8d236195e Mon Sep 17 00:00:00 2001 From: gustavooth Date: Sun, 26 Jul 2026 20:13:45 -0300 Subject: [PATCH] cache update --- .gitignore | 5 +++++ compose.yaml | 38 +++++++++++++++++++++++++++++++++++++- docker/wp-init.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 docker/wp-init.sh diff --git a/.gitignore b/.gitignore index 0f138a6..905be28 100644 --- a/.gitignore +++ b/.gitignore @@ -18,9 +18,14 @@ wp-content/plugins/akismet/ wp-content/plugins/fluentform/ wp-content/plugins/fluent-crm/ wp-content/plugins/fluent-smtp/ +wp-content/plugins/redis-cache/ +wp-content/plugins/query-monitor/ wp-content/plugins/hello.php wp-content/plugins/index.php +# Redis object cache drop-in (auto-installed by wpcli service) +wp-content/object-cache.php + # Keep only project plugins/themes !wp-content/plugins/gustavoo-portfolio-core/ !wp-content/themes/gustavoo-portfolio/ diff --git a/compose.yaml b/compose.yaml index 2892e3a..a519067 100644 --- a/compose.yaml +++ b/compose.yaml @@ -33,7 +33,43 @@ services: depends_on: db: condition: service_healthy + redis: + condition: service_healthy + + redis: + image: redis:7-alpine + volumes: + - redis_data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 10s + + wpcli: + image: wordpress:cli-php8.3 + user: "33:33" + depends_on: + wordpress: + condition: service_started + redis: + condition: service_healthy + environment: + WORDPRESS_DB_HOST: db + WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME} + WORDPRESS_DB_USER: ${WORDPRESS_DB_USER} + WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD} + HOME: /tmp + volumes: + - wordpress_data:/var/www/html + - ./wp-content/themes:/var/www/html/wp-content/themes + - ./wp-content/plugins:/var/www/html/wp-content/plugins + - ./docker/wp-init.sh:/wp-init.sh:ro + entrypoint: ["sh", "/wp-init.sh"] + restart: "no" volumes: db_data: - wordpress_data: \ No newline at end of file + wordpress_data: + redis_data: \ No newline at end of file diff --git a/docker/wp-init.sh b/docker/wp-init.sh new file mode 100644 index 0000000..db81a4b --- /dev/null +++ b/docker/wp-init.sh @@ -0,0 +1,40 @@ +#!/bin/sh +set -e + +echo "[wpcli] Waiting for WordPress core install..." +until wp core is-installed --path=/var/www/html 2>/dev/null; do + sleep 3 +done + +if ! wp language core is-installed pt_BR --path=/var/www/html 2>/dev/null; then + echo "[wpcli] Installing pt_BR language pack..." + wp language core install pt_BR --path=/var/www/html +fi + +echo "[wpcli] Activating pt_BR site language..." +wp language core activate pt_BR --path=/var/www/html + +echo "[wpcli] Setting Redis connection constants..." +wp config set WP_REDIS_HOST redis --type=constant --path=/var/www/html +wp config set WP_REDIS_PORT 6379 --type=constant --raw --path=/var/www/html + +if ! wp plugin is-installed redis-cache --path=/var/www/html; then + echo "[wpcli] Installing Redis Object Cache plugin..." + wp plugin install redis-cache --path=/var/www/html +fi + +echo "[wpcli] Activating Redis Object Cache plugin..." +wp plugin activate redis-cache --path=/var/www/html + +echo "[wpcli] Enabling Redis object cache..." +wp redis enable --path=/var/www/html || wp redis update-dropin --path=/var/www/html + +echo "[wpcli] Redis setup complete." + +if ! wp plugin is-installed query-monitor --path=/var/www/html; then + echo "[wpcli] Installing Query Monitor plugin..." + wp plugin install query-monitor --path=/var/www/html +fi + +echo "[wpcli] Activating Query Monitor plugin..." +wp plugin activate query-monitor --path=/var/www/html