Skip to content

Commit

Permalink
Install xDebug in wp-env
Browse files Browse the repository at this point in the history
  • Loading branch information
noahtallen committed Nov 28, 2020
1 parent 8f90615 commit 9528563
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/env/lib/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ module.exports = function buildDockerComposeConfig( config ) {
volumes: [ 'mysql:/var/lib/mysql' ],
},
wordpress: {
build: '.',
depends_on: [ 'mysql' ],
image: developmentWpImage,
ports: [ developmentPorts ],
Expand Down
24 changes: 24 additions & 0 deletions packages/env/lib/init-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ module.exports = async function initConfig( { spinner, debug } ) {
yaml.dump( dockerComposeConfig )
);

const xDebugMode = 'debug';
await fs.writeFile(
path.resolve( config.workDirectoryPath, 'Dockerfile' ),
dockerFileContents(
dockerComposeConfig.services.wordpress.image,
xDebugMode
)
);

if ( config.debug ) {
spinner.info(
`Config:\n${ JSON.stringify(
Expand All @@ -55,3 +64,18 @@ module.exports = async function initConfig( { spinner, debug } ) {

return config;
};

function dockerFileContents( image, xDebugMode ) {
return `
FROM ${ image }
RUN apt -qy install $PHPIZE_DEPS \\
&& pecl install xdebug \\
&& docker-php-ext-enable xdebug
RUN touch /usr/local/etc/php/php.ini
RUN echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/php.ini
RUN echo 'xdebug.discover_client_host=1' >> /usr/local/etc/php/php.ini
RUN echo 'xdebug.mode=${ xDebugMode }' >> /usr/local/etc/php/php.ini
`;
}

0 comments on commit 9528563

Please sign in to comment.