The situation:
Two computers, two different processor architectures with Docker Desktop running a docker compose
setup which I use to develop a CakePHP application on both machines.
- Windows 11 Pro Workstation which reports
x86_64
whenarch
is run from WSL and Docker Linux containers - Apple Macbook Pro M1 which reports
arm64
from a terminal oraarch64
inside a Linux Docker container whenarch
is run
Problem:
When running Puppeteer inside a Linux aarch64
container on an Apple Silicon Macbook M1 the chromium
version specified in package.json
not available in the aarch64
architecture.
For the x86_64
I use the version of chromium that gets pulled down when using npm i
which is then placed under the project root e.g.:
/var/www/project1/puppeteer/chrome/linux-127.0.6533.88/chrome-linux64/chrome
However on my Macbook M1 (Apple Silicon) there is no arm64
version of Google Chrome or chromium available for download by npm
Mac Apple Silicon work-a-round
So the work-a-round is to install chromium
using the containers package manager apt-get install chromium
and then tell puppeteer where to find it by setting PUPPETEER_EXECUTEABLE_PATH=/usr/bin/chromium
in the Arm64 Linux Container running on the Macbook M1
So to do that you can create an env
file in the same folder as the docker-compose.yaml
file on the Macbook M1 you don't need to create an env
on the Windows WSL environment
1 2 | # ./php.env on Apple Silicon PUPPETEER_EXECUTEABLE_PATH= /usr/bin/chromium |
Once you have your php.env
file (or whatever arbitrary name you give it) you can specify that it is not mandatory by setting required: false
. Any env vars you set in the php.env
file will appear in the docker container when running on Mac and if it doesn't exist (in your Windows WSL environment) it will silently skip pulling it in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # docker-compose.yaml php: restart: unless-stopped env_file: - path : ./php.env required: false build: context: ./docker/config/php/ dockerfile: Dockerfile network: host args: CONTAINER_GID: '${CONTAINER_GID:-1000}' CONTAINER_UID: '${CONTAINER_UID:-1000}' extra_hosts: - 'host.docker.internal:host-gateway' networks: - wms-dev-net volumes: - '${HOME}/.ssh:/home/wms/.ssh' - '.:/var/www/wms' - './bin/bash_completion.sh:/etc/bash_completion.d/cake' - '~/.composer/docker-cache/:/root/.composer:cached' - '~/.config/composer/:/root/.config/composer:cached' - 'vscode-extensions:/root/.vscode-server/extensions' links: - postgres - cups - mailpit |
More information: https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/
0 Comments