diff --git a/bin/docker-compose.override.yml.template b/bin/docker-compose.override.yml.template new file mode 100644 index 00000000000000..465211fe7a4a63 --- /dev/null +++ b/bin/docker-compose.override.yml.template @@ -0,0 +1,17 @@ +services: + wordpress-develop: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + php: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins + - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + cli: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% + phpunit: + volumes: + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% diff --git a/package.json b/package.json index 1b4c65d3dfa112..6ad5baf4760e9c 100644 --- a/package.json +++ b/package.json @@ -236,6 +236,7 @@ ] }, "wp-env": { - "plugin-dir": "gutenberg" + "plugin-dir": "gutenberg", + "docker-template": "./bin/docker-compose.override.yml.template" } } diff --git a/packages/scripts/config/docker-compose.override.yml.template b/packages/scripts/config/docker-compose.override.yml.template index 43d2fc0fddb8fc..092d2df9c3568c 100644 --- a/packages/scripts/config/docker-compose.override.yml.template +++ b/packages/scripts/config/docker-compose.override.yml.template @@ -1,17 +1,13 @@ services: wordpress-develop: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% php: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins - - %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% cli: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% phpunit: volumes: - - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg + - %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR% diff --git a/packages/scripts/scripts/env/connect.js b/packages/scripts/scripts/env/connect.js index 1512d92ef6948c..66db5d4671da66 100644 --- a/packages/scripts/scripts/env/connect.js +++ b/packages/scripts/scripts/env/connect.js @@ -45,8 +45,11 @@ try { const pluginMountDir = normalize( cwd() ); -const composeTemplate = readFileSync( fromConfigRoot( 'docker-compose.override.yml.template' ), 'utf8' ) - .replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir ); +const composeTemplateFile = env.npm_package_wp_env_docker_template ? normalize( cwd() + `/${ env.npm_package_wp_env_docker_template }` ) : fromConfigRoot( 'docker-compose.override.yml.template' ); + +const composeTemplate = readFileSync( composeTemplateFile, 'utf8' ) + .replace( /%PLUGIN_MOUNT_DIR%/gi, pluginMountDir ) + .replace( /%PLUGIN_INSTALL_DIR%/gi, env.npm_package_wp_env_plugin_dir ); const pluginCompose = yaml.safeLoad( composeTemplate ); diff --git a/packages/scripts/scripts/env/install.js b/packages/scripts/scripts/env/install.js index 294f8251b48ddb..fe1ab8ee88a7c1 100644 --- a/packages/scripts/scripts/env/install.js +++ b/packages/scripts/scripts/env/install.js @@ -55,5 +55,5 @@ function buildWordPress() { // Mount Gutenberg into the WordPress install. execSync( 'npm run env connect', { stdio: 'inherit' } ); - execSync( 'npm run env cli plugin activate gutenberg', { stdio: 'inherit' } ); + execSync( `npm run env cli plugin activate ${ env.npm_package_wp_env_plugin_dir }`, { stdio: 'inherit' } ); }