Build/Test Tools: Fix bug pulling local environment containers on Apple silicone.

The MySQL Docker containers for versions 5.7 and below do not support recent Apple silicone chips. Previously this was fixed by including `amd64/` as a prefix to the image name in the `docker-compose.yml` file (see [54096]). However, this stopped working after recent updates to Docker Desktop.

This changeset removes the `amd64/` prefix for the image used as the database container and raises the default version of MySQL in the local development environment to the current LTS version (8.0). Because this version is still maintained, there are `arm64` containers available to use.

This also documents a new workaround for contributors looking to run the local Docker environment using MySQL 5.7 or earlier, which entails creating a small `docker-compose.override.yml`.

Props bernhard-reiter, johnbillion, afragen, huzaifaalmesbah.
Fixes #59930.

git-svn-id: https://develop.svn.wordpress.org/trunk@57568 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2024-02-08 19:10:10 +00:00
parent 9e753cb908
commit b4819647f2
3 changed files with 26 additions and 3 deletions

4
.env
View File

@ -46,12 +46,12 @@ LOCAL_DB_TYPE=mysql
##
# The database version to use.
#
# Defaults to 5.7 with the assumption that LOCAL_DB_TYPE is set to `mysql` above.
# Defaults to 8.0 with the assumption that LOCAL_DB_TYPE is set to `mysql` above.
#
# When using `mysql`, see https://hub.docker.com/r/amd64/mysql for valid versions.
# When using `mariadb`, see https://hub.docker.com/r/amd64/mariadb for valid versions.
##
LOCAL_DB_VERSION=5.7
LOCAL_DB_VERSION=8.0
# The debug settings to add to `wp-config.php`.
LOCAL_WP_DEBUG=true

View File

@ -118,6 +118,29 @@ Starting the environment again is a single command:
npm run env:start
```
#### Resetting the development environment
The development environment can be reset. This will destroy the database and attempt to remove the pulled Docker images.
```
npm run env:reset
```
### Apple Silicone machines and old MySQL versions
The MySQL Docker images do not support Apple Silicone processors (M1, M2, etc.) for MySQL versions 5.7 and earlier.
When using MySQL <= 5.7 on an Apple Silicone machine, you must create a `docker-compose.override.yml` file with the following contents:
```
services:
mysql:
platform: linux/amd64
```
Additionally, the "Use Rosetta for x86/AMD64 emulation on Apple Silicon" setting in Docker needs to be disabled for this workaround.
## Credentials
These are the default environment credentials:

View File

@ -65,7 +65,7 @@ services:
# The MySQL container.
##
mysql:
image: amd64/${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-latest}
image: ${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-latest}
networks:
- wpdevnet