Skip to content

Instantly share code, notes, and snippets.

@tforster
Created November 19, 2021 22:23
Show Gist options
  • Save tforster/876568b999119eb10188fdab5b422ab9 to your computer and use it in GitHub Desktop.
Save tforster/876568b999119eb10188fdab5b422ab9 to your computer and use it in GitHub Desktop.
WordPress with XDebug inside Docker
# Debug state
DEBUG=true
# MySQL configuration
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_HOST=db:3306
# WordPress configuration
WORDPRESS_DB_USER=$DB_USER
WORDPRESS_DB_PASSWORD=$DB_PASSWORD
WORDPRESS_DB_NAME=$DB_NAME
WORDPRESS_DB_HOST=$DB_HOST
WORDPRESS_TABLE_PREFIX=wp_
WP_PATH=$PWD/src/
XDEBUG_INI=$PWD/docker/xdebug.ini
THEME_NAME=
WP_DEBUG=$DEBUG
WP_DEBUG_LOG=$DEBUG
WP_DEBUG_DISPLAY=$DEBUG
CUSTOM_PLUGIN_1=
CUSTOM_PLUGIN_2=
# Docker configuration
WWW_PORT=12348
DB_PORT=12344
COMPOSE_PROJECT_NAME=
ORG=
# WPEngine configuration
WPE_DEV=
WPE_STAGE=
WPE_PROD=
WPE_SITE=$WPE_STAGE
# SSH configuration
SSH_KEY=
version: "3.3"
services:
db:
image: mysql:5.7
restart: always
container_name: db.dev.${ORG}
environment:
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_NAME}
ports:
- "${DB_PORT}:3306"
www:
user: "1000:1000"
image: www.${ORG}:latest
build:
context: .
dockerfile: wordpress.dockerfile
restart: always
container_name: www.dev.${ORG}
environment:
- WORDPRESS_DB_HOST=${DB_HOST}
- WORDPRESS_DB_USER=${DB_USER}
- WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
- WORDPRESS_DB_NAME=${DB_NAME}
- WP_DEBUG=${WP_DEBUG}
volumes:
- ${WP_PATH}:/var/www/html/wp-content:rw
- ${XDEBUG_INI}:/usr/local/etc/php/conf.d/xdebug.ini
ports:
- "${WWW_PORT}:80"
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"log": true,
"port": 9003,
"pathMappings": {
"/var/www/html/wp-content": "${workspaceRoot}/src"
},
"externalConsole": false,
"ignore": [
"**/vendor/**/*.php"
]
}
]
}
FROM wordpress
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
zend_extension=xdebug.so
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.discover_client_host=1
xdebug.log=/tmp/xdebug.log
xdebug.mode=debug
xdebug.start_with_request=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment