Dr Fragen in the operating room

Setting up WordPress local docker environment for Apple Silicon

·

Don’t forget to save any new path commands into .zshrc so the terminal session persists.

  1. Open the Terminal app
  2. Install homebrew
  3. You might be asked if you want to install the Xcode Command Line Tools, confirm.
  4. Install git by typing brew install git
  5. Install Docker on Apple Silicon
  6. Install node via brew install node@16 or brew install node@18, your preference.
    • I install node via nvm, but it’s not necessary
    • Install Node by using nvm ( I use node 16.x at the moment )
      • Open a terminal session
      • brew install nvm
      • Run nvm install 16
      • Run nvm use 16
      • Run nvm alias default 16, so every shell session uses this version of node by default
  7. Install npm via brew install npm@6
    • Switch to npm v6.x via npm install npm@6 -g
    • Make sure you copy path commands to your .zshrc file
  8. Clone the GitHub repository with the wordpress-develop environment.
    • Open a terminal session
    • cd ~
    • git clone https://github.com/WordPress/wordpress-develop.git
    • cd ./wordpress-develop
    • export DOCKER_DEFAULT_PLATFORM=linux/amd64
  9. Open the Docker app in your computer and ignore the welcome screen that tells you to create a container
  10. Now type these commands in the terminal
    • npm install
    • npm run build:dev
    • npm run env:start
    • npm run env:install
  11. You should be able to access the development version of WordPress at localhost:8889. You can access it with username admin and password password
  12. Additional commands
    npm run env:stop
    npm run env:reset

Shortcuts

Initialize

  • Open a terminal session
  • cd ./wordpress-develop
  • export DOCKER_DEFAULT_PLATFORM=linux/amd64
  • Open Docker.app
  • rm -rf node_modules && npm install && npm run build:dev && npm run env:start
  • npm run env:install

May need to re-run npm run env:install if it stalls or errors at end. This is because MySQL may not be ready yet.

Cleanup

  • npm run env:stop && npm run env:reset && rm -rf node_modules
  • Quit Docker Desktop when done.

Run individual tests

  • npm run test:php -- --filter Tests_Admin_IncludesWpUpgrader
  • npm run test:php — –group admin

Don’t commit package-lock.json with your PR to core or you will have issues.