Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/env/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### New Features

- Add a `WP_ENV_MARIADB_VERSION` environment variable to choose the MariaDB version used by the database container ([#83751](https://github.com/WordPress/gutenberg/pull/83751)).
- Add a `WP_ENV_PHP_VERSION` environment variable to choose the PHP version used by the WordPress and WP-CLI containers. It defaults to PHP 7.4, the highest version WordPress 5.5 supports, instead of the `wordpress` and `wordpress:cli` images' default.

### Bug Fixes

Expand Down
2 changes: 2 additions & 0 deletions packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ _Note: the port number environment variables (`WP_ENV_PORT` and `WP_ENV_TESTS_PO

_Note: the MariaDB version can be chosen with the `WP_ENV_MARIADB_VERSION` environment variable, such as `WP_ENV_MARIADB_VERSION=10.5`. It defaults to `latest`. MariaDB cannot start on a database written by a newer version. When switching to a lower version, run `wp-env destroy` first. It removes the environment's Docker containers, volumes, and networks, and its local files, not only the database, so everything is recreated on the next start. With a version older than 11.4, `wp db` commands in the `cli` and `tests-cli` containers fail, and `wp-env clean` leaves the database as it is: the MariaDB client in the `wordpress:cli` image requires TLS, and MariaDB servers before 11.4 do not offer it. `wp-env start` and WordPress itself are not affected. To start over with an empty database, run `wp-env destroy`._

_Note: the PHP version used by the WordPress and WP-CLI containers can be chosen with the `WP_ENV_PHP_VERSION` environment variable, such as `WP_ENV_PHP_VERSION=7.3`, which uses the `wordpress:php7.3` and `wordpress:cli-php7.3` images. It defaults to `7.4`, the highest PHP version WordPress 5.5 supports. It does not change the `phpunit` service, which uses `LOCAL_PHP`._

Several types of strings can be passed into the `core`, `plugins`, `themes`, and `mappings` fields.

| Type | Format | Example(s) |
Expand Down
8 changes: 4 additions & 4 deletions packages/env/lib/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ module.exports = function buildDockerComposeConfig( config ) {
condition: 'service_healthy',
},
},
image: 'wordpress',
image: 'wordpress:php${WP_ENV_PHP_VERSION:-7.4}',
ports: [ developmentPorts ],
environment: {
WORDPRESS_DB_NAME: 'wordpress',
Expand All @@ -181,7 +181,7 @@ module.exports = function buildDockerComposeConfig( config ) {
condition: 'service_healthy',
},
},
image: 'wordpress',
image: 'wordpress:php${WP_ENV_PHP_VERSION:-7.4}',
ports: [ testsPorts ],
environment: {
WORDPRESS_DB_NAME: 'tests-wordpress',
Expand All @@ -193,7 +193,7 @@ module.exports = function buildDockerComposeConfig( config ) {
},
cli: {
depends_on: [ 'wordpress' ],
image: 'wordpress:cli',
image: 'wordpress:cli-php${WP_ENV_PHP_VERSION:-7.4}',
volumes: developmentMounts,
user: cliUser,
environment: {
Expand All @@ -203,7 +203,7 @@ module.exports = function buildDockerComposeConfig( config ) {
},
'tests-cli': {
depends_on: [ 'tests-wordpress' ],
image: 'wordpress:cli',
image: 'wordpress:cli-php${WP_ENV_PHP_VERSION:-7.4}',
volumes: testsMounts,
user: cliUser,
environment: {
Expand Down
15 changes: 15 additions & 0 deletions packages/env/test/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ describe( 'buildDockerComposeConfig', () => {
);
} );

it( 'should let Docker Compose choose the PHP version from WP_ENV_PHP_VERSION', () => {
const { services } = buildDockerComposeConfig( CONFIG );

for ( const service of [ 'wordpress', 'tests-wordpress' ] ) {
expect( services[ service ].image ).toBe(
'wordpress:php${WP_ENV_PHP_VERSION:-7.4}'
);
}
for ( const service of [ 'cli', 'tests-cli' ] ) {
expect( services[ service ].image ).toBe(
'wordpress:cli-php${WP_ENV_PHP_VERSION:-7.4}'
);
}
} );

it( 'should create a separate database for each environment', () => {
const { services } = buildDockerComposeConfig( CONFIG );

Expand Down