game-ci / docker

Series of CI-specialised docker images for Unity.
https://hub.docker.com/u/unityci
MIT License
392 stars 121 forks source link

Unable to Generate Logs and Hanging Execution with unityci/editor Docker Image on Mac with Apple Silicon #238

Open alronz opened 5 months ago

alronz commented 5 months ago

I am trying to use the Docker image unityci/editor:ubuntu-2022.3.18f1-webgl-3.0.1 on a Mac with Apple Silicon (M1/M2) to run the following command after setting the license:

unity-editor -enablePackageManagerTraces -logfile /dev/stdout -quit -batchmode -nographics -buildTarget WebGL -projectPath "/src/Frontend"

Problem Description:

Note that I execute the docker build command with the flag --platform=linux/amd64 since there is no image for arm64

I would appreciate any insights or guidance on how to resolve this issue and make the Docker image work smoothly on Macs with Apple Silicon. Thank you!

GabLeRoux commented 5 months ago

That's a good question, I reproduced this as well. I haven't tried building my own docker image locally on Apple chip (M3 here), but I did reproduce the problem where trying to run unity-editor inside a container and the process did hang without printing anything to console. I even tried with base image (without modules installed).

export DOCKER_DEFAULT_PLATFORM=linux/amd64
docker run -v "$(pwd):/app" --rm docker.io/unityci/editor:2022.3.4f1-base-3 unity-editor \
  -logFile /dev/stdout \
  -quit \
  -serial "$UNITY_SERIAL" \
  -username "$UNITY_EMAIL" \
  -password "$UNITY_PASSWORD" \
  -projectPath "/app/BlankProject"

I'm interested in a solution too. That is an architecture compatibility challenge. I quickly eplored some options.

Rosetta 2

I know there is Rosetta 2, a binary translation layer for running x86_64 applications on ARM architecture. Rosetta can be installed like this:

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

But from there, I'm not sure what would be the next steps, I haven't tried anything past this, but I think running with DOCKER_DEFAULT_PLATFORM=linux/amd64 or --platform=linux/amd64 is already using Rosetta.

Writing a Dockerfile that is ARM compatible

I think for this to work, we'd have to try and use a base image that is already arm compatible and then compile and install dependencies. This is something to explore.

References