From b4819647f29e1b0e259f6496f891ed6539f0d580 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Thu, 8 Feb 2024 19:10:10 +0000 Subject: [PATCH] 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 --- .env | 4 ++-- README.md | 23 +++++++++++++++++++++++ docker-compose.yml | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.env b/.env index d393c9b324..bc22991269 100644 --- a/.env +++ b/.env @@ -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 diff --git a/README.md b/README.md index 9af956b28e..7d71d75f7e 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index 58f4e08d91..bec05ab2a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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