Files
news-platform/wordpress/docker-compose.yml
spark 30bddfbef4
Tests / writer-pipeline tests (push) Successful in 35s
Tests / bridge tests (push) Successful in 35s
Tests / frontend lib tests (push) Successful in 34s
chore(runtime): upgrade WordPress FPM image to php8.4-fpm (BIT-31729)
Paperclip-Issue: BIT-31729
2026-10-23 18:39:06 +01:00

235 lines
9.0 KiB
YAML

services:
db:
image: mariadb:11
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 8
start_period: 90s
wordpress:
image: wordpress:6-php8.4-fpm
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
WORDPRESS_TABLE_PREFIX: wp_
# Browser-facing URL (must match how users open the site). Required when Nginx proxies
# /wp-admin/ on https://newsproject.bitreport.pt → container :8080; otherwise WP redirects
# to http://localhost:8080/wp-login.php.
WORDPRESS_PUBLIC_URL: ${WORDPRESS_PUBLIC_URL:-http://localhost:8080}
# Set WORDPRESS_DEBUG=1 in .env only for short-lived triage on the CT (exposes errors in HTML).
WORDPRESS_DEBUG: ${WORDPRESS_DEBUG:-0}
# Disable WordPress cron (use system cron instead)
# Docker Compose interpolates $… in env values; $$ → literal $ for PHP (e.g. $$_SERVER → $_SERVER).
WORDPRESS_CONFIG_EXTRA: |
define('DISABLE_WP_CRON', true);
$$_wp_dbg = getenv('WORDPRESS_DEBUG');
$$_wp_debug_on = ($$_wp_dbg !== false && $$_wp_dbg !== '' && $$_wp_dbg !== '0' && strtolower((string) $$_wp_dbg) !== 'false' && strtolower((string) $$_wp_dbg) !== 'no');
define('WP_DEBUG', $$_wp_debug_on);
define('WP_DEBUG_LOG', $$_wp_debug_on);
define('WP_DEBUG_DISPLAY', $$_wp_debug_on);
define('SCRIPT_DEBUG', $$_wp_debug_on);
if ($$_wp_debug_on) {
error_reporting(E_ALL);
@ini_set('display_errors', '1');
}
/* REST API — allow all origins for bridge access */
define('REST_API_ENABLED', true);
$$_wp_public_url = getenv('WORDPRESS_PUBLIC_URL');
if ($$_wp_public_url === false || $$_wp_public_url === '') {
$$_wp_public_url = 'http://localhost:8080';
}
$$_wp_public_url = rtrim($$_wp_public_url, '/');
/* If .env still defaults to the container URL but traffic comes via CT nginx (NPM → CT),
* infer WP_HOME from Host + X-Forwarded-Proto. Accept any standard reverse-proxy hint
* (X-Forwarded-Proto / X-Forwarded-For / X-Real-IP) — some edge proxies omit X-Forwarded-For.
* Raw :8080 access without those headers keeps local behaviour. */
$$_container_local = in_array($$_wp_public_url, array('http://localhost:8080', 'http://127.0.0.1:8080'), true);
$$_proxy_hint = !empty($$_SERVER['HTTP_X_FORWARDED_FOR'])
|| !empty($$_SERVER['HTTP_X_FORWARDED_PROTO'])
|| !empty($$_SERVER['HTTP_X_REAL_IP']);
if ($$_container_local
&& !empty($$_SERVER['HTTP_HOST'])
&& strpos($$_SERVER['HTTP_HOST'], 'localhost') === false
&& strpos($$_SERVER['HTTP_HOST'], '127.0.0.1') === false
&& $$_proxy_hint
) {
$$_proto = 'http';
if (!empty($$_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$$_first = strtolower(trim(strtok($$_SERVER['HTTP_X_FORWARDED_PROTO'], ',')));
if ($$_first === 'https') {
$$_proto = 'https';
}
} elseif (!empty($$_SERVER['HTTPS']) && $$_SERVER['HTTPS'] !== 'off') {
$$_proto = 'https';
}
$$_wp_public_url = $$_proto . '://' . $$_SERVER['HTTP_HOST'];
}
define('WP_HOME', $$_wp_public_url);
define('WP_SITEURL', $$_wp_public_url);
if (!empty($$_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$$_xf_proto = strtolower(trim(strtok($$_SERVER['HTTP_X_FORWARDED_PROTO'], ',')));
if ($$_xf_proto === 'https') {
$$_SERVER['HTTPS'] = 'on';
}
}
volumes:
- wp_html:/var/www/html
- wp_content:/var/www/html/wp-content
- ./php.ini:/usr/local/etc/php/conf.d/custom.ini:ro
healthcheck:
test: ["CMD-SHELL", "php -r \"exit(@fsockopen('127.0.0.1',9000)?0:1);\""]
interval: 10s
timeout: 5s
retries: 8
start_period: 90s
nginx:
image: nginx:alpine
restart: unless-stopped
depends_on:
wordpress:
condition: service_healthy
ports:
- "8080:80"
volumes:
- wp_html:/var/www/html:ro
- ./nginx/wordpress.conf:/etc/nginx/conf.d/default.conf:ro
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/wp-json/wp/v2/"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
db-andebol:
image: mariadb:11
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${ANDEBOL_MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: wordpress_andebol
MYSQL_USER: wordpress
MYSQL_PASSWORD: ${ANDEBOL_MYSQL_PASSWORD}
volumes:
- db_andebol_data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 8
start_period: 90s
wordpress-andebol:
image: wordpress:6-php8.4-fpm
restart: unless-stopped
depends_on:
db-andebol:
condition: service_healthy
environment:
WORDPRESS_DB_HOST: db-andebol:3306
WORDPRESS_DB_NAME: wordpress_andebol
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: ${ANDEBOL_MYSQL_PASSWORD}
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_PUBLIC_URL: ${ANDEBOL_WORDPRESS_PUBLIC_URL:-http://localhost:8081}
WORDPRESS_DEBUG: ${WORDPRESS_DEBUG:-0}
WORDPRESS_CONFIG_EXTRA: |
define('DISABLE_WP_CRON', true);
$$_wp_dbg = getenv('WORDPRESS_DEBUG');
$$_wp_debug_on = ($$_wp_dbg !== false && $$_wp_dbg !== '' && $$_wp_dbg !== '0' && strtolower((string) $$_wp_dbg) !== 'false' && strtolower((string) $$_wp_dbg) !== 'no');
define('WP_DEBUG', $$_wp_debug_on);
define('WP_DEBUG_LOG', $$_wp_debug_on);
define('WP_DEBUG_DISPLAY', $$_wp_debug_on);
define('SCRIPT_DEBUG', $$_wp_debug_on);
if ($$_wp_debug_on) {
error_reporting(E_ALL);
@ini_set('display_errors', '1');
}
define('REST_API_ENABLED', true);
$$_wp_public_url = getenv('WORDPRESS_PUBLIC_URL');
if ($$_wp_public_url === false || $$_wp_public_url === '') {
$$_wp_public_url = 'http://localhost:8081';
}
$$_wp_public_url = rtrim($$_wp_public_url, '/');
$$_container_local = in_array($$_wp_public_url, array('http://localhost:8081', 'http://127.0.0.1:8081'), true);
$$_proxy_hint = !empty($$_SERVER['HTTP_X_FORWARDED_FOR'])
|| !empty($$_SERVER['HTTP_X_FORWARDED_PROTO'])
|| !empty($$_SERVER['HTTP_X_REAL_IP']);
if ($$_container_local
&& !empty($$_SERVER['HTTP_HOST'])
&& strpos($$_SERVER['HTTP_HOST'], 'localhost') === false
&& strpos($$_SERVER['HTTP_HOST'], '127.0.0.1') === false
&& $$_proxy_hint
) {
$$_proto = 'http';
if (!empty($$_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$$_first = strtolower(trim(strtok($$_SERVER['HTTP_X_FORWARDED_PROTO'], ',')));
if ($$_first === 'https') {
$$_proto = 'https';
}
} elseif (!empty($$_SERVER['HTTPS']) && $$_SERVER['HTTPS'] !== 'off') {
$$_proto = 'https';
}
$$_wp_public_url = $$_proto . '://' . $$_SERVER['HTTP_HOST'];
}
define('WP_HOME', $$_wp_public_url);
define('WP_SITEURL', $$_wp_public_url);
if (!empty($$_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$$_xf_proto = strtolower(trim(strtok($$_SERVER['HTTP_X_FORWARDED_PROTO'], ',')));
if ($$_xf_proto === 'https') {
$$_SERVER['HTTPS'] = 'on';
}
}
volumes:
- wp_andebol_html:/var/www/html
- wp_andebol_content:/var/www/html/wp-content
- ./php.ini:/usr/local/etc/php/conf.d/custom.ini:ro
healthcheck:
test: ["CMD-SHELL", "php -r \"exit(@fsockopen('127.0.0.1',9000)?0:1);\""]
interval: 10s
timeout: 5s
retries: 8
start_period: 90s
nginx-andebol:
image: nginx:alpine
restart: unless-stopped
depends_on:
wordpress-andebol:
condition: service_healthy
ports:
- "8081:80"
volumes:
- wp_andebol_html:/var/www/html:ro
- wp_andebol_content:/var/www/html/wp-content:ro
- ./nginx/wordpress-andebol.conf:/etc/nginx/conf.d/default.conf:ro
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/wp-json/wp/v2/"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
volumes:
db_data:
wp_html:
wp_content:
db_andebol_data:
wp_andebol_html:
wp_andebol_content: