From 27425373ee7144e8b23da4a2ff7a5cc40409b296 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 11 Mar 2021 13:17:10 +0100 Subject: [PATCH 1/9] Fix wp-env docker-compose config with explicit users and passwords --- .../env/lib/build-docker-compose-config.js | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index 668836de88878..ab186eb75ce08 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -176,9 +176,17 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes', + MYSQL_ROOT_PASSWORD: 'password', + MYSQL_DATABASE: 'wordpress', + }, + }, + 'tests-mysql': { + image: 'mariadb', + ports: [ '3306' ], + environment: { + MYSQL_ROOT_PASSWORD: 'password', + MYSQL_DATABASE: 'tests-wordpress', }, - volumes: [ 'mysql:/var/lib/mysql' ], }, wordpress: { build: '.', @@ -187,15 +195,20 @@ module.exports = function buildDockerComposeConfig( config ) { ports: [ developmentPorts ], environment: { WORDPRESS_DB_NAME: 'wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', }, volumes: developmentMounts, }, 'tests-wordpress': { - depends_on: [ 'mysql' ], + depends_on: [ 'tests-mysql' ], image: testsWpImage, ports: [ testsPorts ], environment: { WORDPRESS_DB_NAME: 'tests-wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', + WORDPRESS_DB_HOST: 'tests-mysql', }, volumes: testsMounts, }, @@ -204,12 +217,23 @@ module.exports = function buildDockerComposeConfig( config ) { image: developmentWpCliImage, volumes: developmentMounts, user: cliUser, + environment: { + WORDPRESS_DB_NAME: 'wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', + }, }, 'tests-cli': { depends_on: [ 'tests-wordpress' ], image: testsWpCliImage, volumes: testsMounts, user: cliUser, + environment: { + WORDPRESS_DB_NAME: 'tests-wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', + WORDPRESS_DB_HOST: 'tests-mysql', + }, }, composer: { image: 'composer', From 7d660da4e1b05ada947d20b5c8f51d5eaa1e683c Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 11 Mar 2021 16:01:17 +0100 Subject: [PATCH 2/9] try restoring mysql volumes --- packages/env/lib/build-docker-compose-config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index ab186eb75ce08..cb51bdc9490bf 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -179,6 +179,7 @@ module.exports = function buildDockerComposeConfig( config ) { MYSQL_ROOT_PASSWORD: 'password', MYSQL_DATABASE: 'wordpress', }, + volumes: [ 'mysql:/var/lib/mysql' ], }, 'tests-mysql': { image: 'mariadb', @@ -187,6 +188,7 @@ module.exports = function buildDockerComposeConfig( config ) { MYSQL_ROOT_PASSWORD: 'password', MYSQL_DATABASE: 'tests-wordpress', }, + volumes: [ 'mysql-test:/var/lib/mysql' ], }, wordpress: { build: '.', @@ -259,6 +261,7 @@ module.exports = function buildDockerComposeConfig( config ) { ...( ! config.coreSource && { wordpress: {} } ), ...( ! config.coreSource && { 'tests-wordpress': {} } ), mysql: {}, + 'mysql-test': {}, 'phpunit-uploads': {}, }, }; From 1f5efe775b54f2e80566f54584e7b1a2a5231e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ribari=C4=87?= Date: Thu, 11 Mar 2021 20:39:27 +0100 Subject: [PATCH 3/9] Fix wp-config.php is not writable error --- packages/env/lib/commands/start.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/env/lib/commands/start.js b/packages/env/lib/commands/start.js index 22fe075948c4a..d26654f6b36a3 100644 --- a/packages/env/lib/commands/start.js +++ b/packages/env/lib/commands/start.js @@ -140,6 +140,27 @@ module.exports = async function start( { spinner, debug, update, xdebug } ) { : [], } ); + await dockerCompose.exec( 'wordpress', 'chown www-data:www-data wp-config.php', { + config: dockerComposeConfigPath, + log: debug, + } ) + + await dockerCompose.exec( 'wordpress', 'chmod 777 wp-config.php', { + config: dockerComposeConfigPath, + log: debug, + } ) + + await dockerCompose.exec( 'tests-wordpress', 'chown www-data:www-data wp-config.php', { + config: dockerComposeConfigPath, + log: debug, + } ) + + await dockerCompose.exec( 'tests-wordpress', 'chmod 777 wp-config.php', { + config: dockerComposeConfigPath, + log: debug, + } ) + + // Only run WordPress install/configuration when config has changed. if ( shouldConfigureWp ) { spinner.text = 'Configuring WordPress.'; From 42058f4f42a4358c1e7eccad11bd4842d22d03c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ribari=C4=87?= Date: Thu, 11 Mar 2021 21:26:29 +0100 Subject: [PATCH 4/9] Cleaner fix implementation --- packages/env/lib/commands/start.js | 25 +++++-------------------- packages/env/lib/wordpress.js | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/env/lib/commands/start.js b/packages/env/lib/commands/start.js index d26654f6b36a3..4f3a00cc927dd 100644 --- a/packages/env/lib/commands/start.js +++ b/packages/env/lib/commands/start.js @@ -24,6 +24,7 @@ const downloadSources = require( '../download-sources' ); const { checkDatabaseConnection, makeContentDirectoriesWritable, + makeConfigWritable, configureWordPress, setupWordPressDirectories, } = require( '../wordpress' ); @@ -140,26 +141,10 @@ module.exports = async function start( { spinner, debug, update, xdebug } ) { : [], } ); - await dockerCompose.exec( 'wordpress', 'chown www-data:www-data wp-config.php', { - config: dockerComposeConfigPath, - log: debug, - } ) - - await dockerCompose.exec( 'wordpress', 'chmod 777 wp-config.php', { - config: dockerComposeConfigPath, - log: debug, - } ) - - await dockerCompose.exec( 'tests-wordpress', 'chown www-data:www-data wp-config.php', { - config: dockerComposeConfigPath, - log: debug, - } ) - - await dockerCompose.exec( 'tests-wordpress', 'chmod 777 wp-config.php', { - config: dockerComposeConfigPath, - log: debug, - } ) - + await Promise.all( [ + makeConfigWritable( 'development', config ), + makeConfigWritable( 'tests', config ), + ] ); // Only run WordPress install/configuration when config has changed. if ( shouldConfigureWp ) { diff --git a/packages/env/lib/wordpress.js b/packages/env/lib/wordpress.js index 07705167ac1dc..7d19ab0d9b87d 100644 --- a/packages/env/lib/wordpress.js +++ b/packages/env/lib/wordpress.js @@ -47,6 +47,27 @@ async function makeContentDirectoriesWritable( ); } +/** + * Makes wp-config.php owned by www-data so that WordPress can work with the + * file. + * + * @param {WPEnvironment} environment The environment to check. Either 'development' or 'tests'. + * @param {WPConfig} config The wp-env config object. + */ +async function makeConfigWritable( + environment, + { dockerComposeConfigPath, debug } +) { + await dockerCompose.exec( + environment === 'development' ? 'wordpress' : 'tests-wordpress', + 'chown www-data:www-data wp-config.php', + { + config: dockerComposeConfigPath, + log: debug, + } + ); +} + /** * Checks a WordPress database connection. An error is thrown if the test is * unsuccessful. From 3f2c8af05032b2e77a3fbdf8419ce1198102ac9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ribari=C4=87?= Date: Thu, 11 Mar 2021 22:00:30 +0100 Subject: [PATCH 5/9] Export new function --- packages/env/lib/wordpress.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/env/lib/wordpress.js b/packages/env/lib/wordpress.js index 7d19ab0d9b87d..da632f9703b5b 100644 --- a/packages/env/lib/wordpress.js +++ b/packages/env/lib/wordpress.js @@ -281,6 +281,7 @@ async function copyCoreFiles( fromPath, toPath ) { module.exports = { hasSameCoreSource, makeContentDirectoriesWritable, + makeConfigWritable, checkDatabaseConnection, configureWordPress, resetDatabase, From a982f82a033081b0194b53da9ea7cb7f8340727f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ribari=C4=87?= Date: Fri, 12 Mar 2021 00:58:19 +0100 Subject: [PATCH 6/9] Abstract db environment into constants --- .../env/lib/build-docker-compose-config.js | 31 ++++++++----------- packages/env/lib/config/db-env.js | 23 ++++++++++++++ packages/env/lib/config/index.js | 2 ++ 3 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 packages/env/lib/config/db-env.js diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index cb51bdc9490bf..6a4eea7f4a7a7 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -9,6 +9,7 @@ const path = require( 'path' ); * Internal dependencies */ const { hasSameCoreSource } = require( './wordpress' ); +const { dbEnv } = require( './config' ); /** * @typedef {import('./config').WPConfig} WPConfig @@ -176,8 +177,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ROOT_PASSWORD: 'password', - MYSQL_DATABASE: 'wordpress', + MYSQL_ROOT_PASSWORD: dbEnv.credentials.password, + MYSQL_DATABASE: dbEnv.development.WORDPRESS_DB_NAME, }, volumes: [ 'mysql:/var/lib/mysql' ], }, @@ -185,8 +186,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ROOT_PASSWORD: 'password', - MYSQL_DATABASE: 'tests-wordpress', + MYSQL_ROOT_PASSWORD: dbEnv.credentials.password, + MYSQL_DATABASE: dbEnv.tests.WORDPRESS_DB_NAME, }, volumes: [ 'mysql-test:/var/lib/mysql' ], }, @@ -196,9 +197,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: developmentWpImage, ports: [ developmentPorts ], environment: { - WORDPRESS_DB_NAME: 'wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', + ...dbEnv.credentials, + ...dbEnv.development, }, volumes: developmentMounts, }, @@ -207,10 +207,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: testsWpImage, ports: [ testsPorts ], environment: { - WORDPRESS_DB_NAME: 'tests-wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', - WORDPRESS_DB_HOST: 'tests-mysql', + ...dbEnv.credentials, + ...dbEnv.tests, }, volumes: testsMounts, }, @@ -220,9 +218,8 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: developmentMounts, user: cliUser, environment: { - WORDPRESS_DB_NAME: 'wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', + ...dbEnv.credentials, + ...dbEnv.development, }, }, 'tests-cli': { @@ -231,10 +228,8 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: testsMounts, user: cliUser, environment: { - WORDPRESS_DB_NAME: 'tests-wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', - WORDPRESS_DB_HOST: 'tests-mysql', + ...dbEnv.credentials, + ...dbEnv.tests, }, }, composer: { diff --git a/packages/env/lib/config/db-env.js b/packages/env/lib/config/db-env.js new file mode 100644 index 0000000000000..6f06ff9731510 --- /dev/null +++ b/packages/env/lib/config/db-env.js @@ -0,0 +1,23 @@ +// Username and password used in all databases +const credentials = { + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', +}; + +// Environment for test database +const tests = { + WORDPRESS_DB_NAME: 'tests-wordpress', + WORDPRESS_DB_HOST: 'tests-mysql', +}; + +// Environment for development database. DB host gets default value which is set +// elsewhere +const development = { + WORDPRESS_DB_NAME: 'wordpress', +}; + +module.exports = { + credentials, + tests, + development, +}; diff --git a/packages/env/lib/config/index.js b/packages/env/lib/config/index.js index 0dbbcc08a5b8a..1a944f43501d0 100644 --- a/packages/env/lib/config/index.js +++ b/packages/env/lib/config/index.js @@ -3,6 +3,7 @@ */ const readConfig = require( './config' ); const { ValidationError } = require( './validate-config' ); +const dbEnv = require( './db-env' ); /** * @typedef {import('./config').WPConfig} WPConfig @@ -13,4 +14,5 @@ const { ValidationError } = require( './validate-config' ); module.exports = { ValidationError, readConfig, + dbEnv, }; From d62f7b830a6b7dfa8d2f98e8a7b5989e1a205cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ribari=C4=87?= Date: Fri, 12 Mar 2021 01:10:05 +0100 Subject: [PATCH 7/9] Revert "Abstract db environment into constants" This reverts commit a982f82a033081b0194b53da9ea7cb7f8340727f. --- .../env/lib/build-docker-compose-config.js | 31 +++++++++++-------- packages/env/lib/config/db-env.js | 23 -------------- packages/env/lib/config/index.js | 2 -- 3 files changed, 18 insertions(+), 38 deletions(-) delete mode 100644 packages/env/lib/config/db-env.js diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index 6a4eea7f4a7a7..cb51bdc9490bf 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -9,7 +9,6 @@ const path = require( 'path' ); * Internal dependencies */ const { hasSameCoreSource } = require( './wordpress' ); -const { dbEnv } = require( './config' ); /** * @typedef {import('./config').WPConfig} WPConfig @@ -177,8 +176,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ROOT_PASSWORD: dbEnv.credentials.password, - MYSQL_DATABASE: dbEnv.development.WORDPRESS_DB_NAME, + MYSQL_ROOT_PASSWORD: 'password', + MYSQL_DATABASE: 'wordpress', }, volumes: [ 'mysql:/var/lib/mysql' ], }, @@ -186,8 +185,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ROOT_PASSWORD: dbEnv.credentials.password, - MYSQL_DATABASE: dbEnv.tests.WORDPRESS_DB_NAME, + MYSQL_ROOT_PASSWORD: 'password', + MYSQL_DATABASE: 'tests-wordpress', }, volumes: [ 'mysql-test:/var/lib/mysql' ], }, @@ -197,8 +196,9 @@ module.exports = function buildDockerComposeConfig( config ) { image: developmentWpImage, ports: [ developmentPorts ], environment: { - ...dbEnv.credentials, - ...dbEnv.development, + WORDPRESS_DB_NAME: 'wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', }, volumes: developmentMounts, }, @@ -207,8 +207,10 @@ module.exports = function buildDockerComposeConfig( config ) { image: testsWpImage, ports: [ testsPorts ], environment: { - ...dbEnv.credentials, - ...dbEnv.tests, + WORDPRESS_DB_NAME: 'tests-wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', + WORDPRESS_DB_HOST: 'tests-mysql', }, volumes: testsMounts, }, @@ -218,8 +220,9 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: developmentMounts, user: cliUser, environment: { - ...dbEnv.credentials, - ...dbEnv.development, + WORDPRESS_DB_NAME: 'wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', }, }, 'tests-cli': { @@ -228,8 +231,10 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: testsMounts, user: cliUser, environment: { - ...dbEnv.credentials, - ...dbEnv.tests, + WORDPRESS_DB_NAME: 'tests-wordpress', + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', + WORDPRESS_DB_HOST: 'tests-mysql', }, }, composer: { diff --git a/packages/env/lib/config/db-env.js b/packages/env/lib/config/db-env.js deleted file mode 100644 index 6f06ff9731510..0000000000000 --- a/packages/env/lib/config/db-env.js +++ /dev/null @@ -1,23 +0,0 @@ -// Username and password used in all databases -const credentials = { - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', -}; - -// Environment for test database -const tests = { - WORDPRESS_DB_NAME: 'tests-wordpress', - WORDPRESS_DB_HOST: 'tests-mysql', -}; - -// Environment for development database. DB host gets default value which is set -// elsewhere -const development = { - WORDPRESS_DB_NAME: 'wordpress', -}; - -module.exports = { - credentials, - tests, - development, -}; diff --git a/packages/env/lib/config/index.js b/packages/env/lib/config/index.js index 1a944f43501d0..0dbbcc08a5b8a 100644 --- a/packages/env/lib/config/index.js +++ b/packages/env/lib/config/index.js @@ -3,7 +3,6 @@ */ const readConfig = require( './config' ); const { ValidationError } = require( './validate-config' ); -const dbEnv = require( './db-env' ); /** * @typedef {import('./config').WPConfig} WPConfig @@ -14,5 +13,4 @@ const dbEnv = require( './db-env' ); module.exports = { ValidationError, readConfig, - dbEnv, }; From 0ca4422e350405b69d54a28a69db13433d38b43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ribari=C4=87?= Date: Fri, 12 Mar 2021 00:58:19 +0100 Subject: [PATCH 8/9] Abstract db environment into constants --- .../env/lib/build-docker-compose-config.js | 33 +++++++++---------- packages/env/lib/config/db-env.js | 23 +++++++++++++ packages/env/lib/config/index.js | 2 ++ 3 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 packages/env/lib/config/db-env.js diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index cb51bdc9490bf..f72ea694b8ba1 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -9,6 +9,7 @@ const path = require( 'path' ); * Internal dependencies */ const { hasSameCoreSource } = require( './wordpress' ); +const { dbEnv } = require( './config' ); /** * @typedef {import('./config').WPConfig} WPConfig @@ -176,8 +177,9 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ROOT_PASSWORD: 'password', - MYSQL_DATABASE: 'wordpress', + MYSQL_ROOT_PASSWORD: + dbEnv.credentials.WORDPRESS_DB_PASSWORD, + MYSQL_DATABASE: dbEnv.development.WORDPRESS_DB_NAME, }, volumes: [ 'mysql:/var/lib/mysql' ], }, @@ -185,8 +187,9 @@ module.exports = function buildDockerComposeConfig( config ) { image: 'mariadb', ports: [ '3306' ], environment: { - MYSQL_ROOT_PASSWORD: 'password', - MYSQL_DATABASE: 'tests-wordpress', + MYSQL_ROOT_PASSWORD: + dbEnv.credentials.WORDPRESS_DB_PASSWORD, + MYSQL_DATABASE: dbEnv.tests.WORDPRESS_DB_NAME, }, volumes: [ 'mysql-test:/var/lib/mysql' ], }, @@ -196,9 +199,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: developmentWpImage, ports: [ developmentPorts ], environment: { - WORDPRESS_DB_NAME: 'wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', + ...dbEnv.credentials, + ...dbEnv.development, }, volumes: developmentMounts, }, @@ -207,10 +209,8 @@ module.exports = function buildDockerComposeConfig( config ) { image: testsWpImage, ports: [ testsPorts ], environment: { - WORDPRESS_DB_NAME: 'tests-wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', - WORDPRESS_DB_HOST: 'tests-mysql', + ...dbEnv.credentials, + ...dbEnv.tests, }, volumes: testsMounts, }, @@ -220,9 +220,8 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: developmentMounts, user: cliUser, environment: { - WORDPRESS_DB_NAME: 'wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', + ...dbEnv.credentials, + ...dbEnv.development, }, }, 'tests-cli': { @@ -231,10 +230,8 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: testsMounts, user: cliUser, environment: { - WORDPRESS_DB_NAME: 'tests-wordpress', - WORDPRESS_DB_USER: 'root', - WORDPRESS_DB_PASSWORD: 'password', - WORDPRESS_DB_HOST: 'tests-mysql', + ...dbEnv.credentials, + ...dbEnv.tests, }, }, composer: { diff --git a/packages/env/lib/config/db-env.js b/packages/env/lib/config/db-env.js new file mode 100644 index 0000000000000..6f06ff9731510 --- /dev/null +++ b/packages/env/lib/config/db-env.js @@ -0,0 +1,23 @@ +// Username and password used in all databases +const credentials = { + WORDPRESS_DB_USER: 'root', + WORDPRESS_DB_PASSWORD: 'password', +}; + +// Environment for test database +const tests = { + WORDPRESS_DB_NAME: 'tests-wordpress', + WORDPRESS_DB_HOST: 'tests-mysql', +}; + +// Environment for development database. DB host gets default value which is set +// elsewhere +const development = { + WORDPRESS_DB_NAME: 'wordpress', +}; + +module.exports = { + credentials, + tests, + development, +}; diff --git a/packages/env/lib/config/index.js b/packages/env/lib/config/index.js index 0dbbcc08a5b8a..1a944f43501d0 100644 --- a/packages/env/lib/config/index.js +++ b/packages/env/lib/config/index.js @@ -3,6 +3,7 @@ */ const readConfig = require( './config' ); const { ValidationError } = require( './validate-config' ); +const dbEnv = require( './db-env' ); /** * @typedef {import('./config').WPConfig} WPConfig @@ -13,4 +14,5 @@ const { ValidationError } = require( './validate-config' ); module.exports = { ValidationError, readConfig, + dbEnv, }; From 9a7f8c3ba15ae8c3deb7dd3a834b5adbbd83ccaf Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Thu, 11 Mar 2021 18:26:31 -0800 Subject: [PATCH 9/9] Add db credentials to phpunit image --- packages/env/lib/build-docker-compose-config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index f72ea694b8ba1..b17cb7bb58212 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -251,6 +251,8 @@ module.exports = function buildDockerComposeConfig( config ) { LOCAL_DIR: 'html', WP_PHPUNIT__TESTS_CONFIG: '/var/www/html/phpunit-wp-config.php', + ...dbEnv.credentials, + ...dbEnv.tests, }, }, },