services: ## # The web server container. ## wordpress-develop: image: nginx:alpine networks: - wpdevnet ports: - ${LOCAL_PORT-8889}:80 environment: LOCAL_DIR: ${LOCAL_DIR-src} LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION:-off} LOCAL_NGINX_STATIC_EXPIRES: ${LOCAL_NGINX_STATIC_EXPIRES:-off} volumes: - ./tools/local-env/default.template:/etc/nginx/conf.d/default.template - ./:/var/www # Load our config file, substituting environment variables into the config. command: /bin/sh -c "envsubst '$$LOCAL_DIR $$LOCAL_NGINX_COMPRESSION $$LOCAL_NGINX_STATIC_EXPIRES' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" depends_on: php: condition: service_started mysql: condition: service_healthy ## # The PHP container. ## php: image: wordpressdevelop/php:${LOCAL_PHP-latest} networks: - wpdevnet environment: LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false} XDEBUG_MODE: ${LOCAL_PHP_XDEBUG_MODE-develop,debug} LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false} PHP_FPM_UID: ${PHP_FPM_UID-1000} PHP_FPM_GID: ${PHP_FPM_GID-1000} GITHUB_REF: ${GITHUB_REF-false} GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME-false} HOST_PATH: ${PWD-}/${LOCAL_DIR-src} volumes: - ./tools/local-env/php-config.ini:/usr/local/etc/php/conf.d/php-config.ini - ./:/var/www # Install the loopback-request shim (see tools/local-env/mu-plugins/fix-docker-loopback.php), then # copy or delete the Memcached dropin plugin file as appropriate. The shim is only installed when wp-content already # exists, so that a not-yet-built LOCAL_DIR (e.g. build) is not created here as root, which would block the build. command: >- /bin/sh -c " if [ -d /var/www/${LOCAL_DIR-src}/wp-content ]; then mkdir -m 777 -p /var/www/${LOCAL_DIR-src}/wp-content/mu-plugins && sed -e '2a\\ * ⚠️ DO NOT EDIT THIS FILE. It is overwritten whenever the environment starts. Edit tools/local-env/mu-plugins/fix-docker-loopback.php instead.' -e '2a\\ *' /var/www/tools/local-env/mu-plugins/fix-docker-loopback.php > /var/www/${LOCAL_DIR-src}/wp-content/mu-plugins/fix-docker-loopback.php; fi; if [ $LOCAL_PHP_MEMCACHED = true ]; then cp -n /var/www/tests/phpunit/includes/object-cache.php /var/www/src/wp-content/object-cache.php; else rm -f /var/www/src/wp-content/object-cache.php; fi && exec php-fpm " # The init directive ensures the command runs with a PID > 1, so Ctrl+C works correctly. init: true extra_hosts: - localhost:host-gateway - host.docker.internal:host-gateway ## # The MySQL container. ## mysql: image: ${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-latest} networks: - wpdevnet ports: - "${LOCAL_DB_PORTS-3306}" environment: MYSQL_ROOT_PASSWORD: password volumes: - ./tools/local-env/mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql - mysql:/var/lib/mysql # Ping over TCP: the client resolves the literal `localhost` to the Unix socket, which the # temporary `--skip-networking` server used to initialise a cold volume answers long before # the real server listens on port 3306. healthcheck: test: [ 'CMD-SHELL', 'if [ "$LOCAL_DB_TYPE" = "mariadb" ]; then case "$LOCAL_DB_VERSION" in 5.5|10.0|10.1|10.2|10.3) mysqladmin ping -h 127.0.0.1 --protocol=tcp || exit $$?;; *) mariadb-admin ping -h 127.0.0.1 --protocol=tcp || exit $$?;; esac; else mysqladmin ping -h 127.0.0.1 --protocol=tcp || exit $$?; fi' ] timeout: 5s interval: 5s retries: 10 start_period: 60s ## # The WP CLI container. ## cli: image: wordpressdevelop/cli:${LOCAL_PHP-latest} networks: - wpdevnet environment: LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false} LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false} PHP_FPM_UID: ${PHP_FPM_UID-1000} PHP_FPM_GID: ${PHP_FPM_GID-1000} HOST_PATH: ${PWD-}/${LOCAL_DIR-src} WP_CONFIG_PATH: /var/www/wp-config.php volumes: - ./:/var/www # Keeps the service alive. command: 'sleep infinity' # The init directive ensures the command runs with a PID > 1, so Ctrl+C works correctly. init: true extra_hosts: - localhost:host-gateway - host.docker.internal:host-gateway depends_on: php: condition: service_started mysql: condition: service_healthy ## # The Memcached container. ## memcached: image: memcached networks: - wpdevnet ports: - 11211:11211 depends_on: php: condition: service_started volumes: # So that sites aren't wiped every time containers are restarted, MySQL uses a persistent volume. mysql: {} networks: # Creating our own network allows us to connect between containers using their service name. wpdevnet: driver: bridge