My goal
I'd like to be able to use the repo2docker-action to create a Docker image based of the configuration files in my repository.
What is working
I am able to successfully create such an image under name brewer36/jupyter-mentor:latest with the following GitHub actions configuration:
name: Build Notebook Container
on: [push, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout files in repo
uses: actions/checkout@main
- name: update jupyter dependencies with repo2docker
uses: jupyterhub/repo2docker-action@master
with:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
The problem
My problem is that I'm finding it difficult to get GitHub actions to create a Docker image that is compatible with the Mac M1 chip, which has arm64 architecture. All of my attempts thus far, no matter what configuration variables I use, result in an amd64 image. Docker warns me that that this image may have poor performance or fail, because the image is based off of a different architecture.
What I have been able to get working
As debugging a remote action is time consuming and difficult, I started first trying to make progress locally. I installed repo2docker and looked at various issues discussing how to make repo2docker work with a Mac M1. Issue #1174 was helpful because it showed me how to specify extra build args that are not in the repo2docker documentation on the web (it is only available by running repo2docker --help-all
). Specifically the argument --Repo2Docker.extra_build_args=platform=linux/amd64
. Using this flag, I am able to build a similar Docker image on my local machine using the command
repo2docker --Repo2Docker.platform=linux/arm64 --image-name=brewer36/jupyter-mentor:macos ./
where ./
refers to the current directory, which is the base directory of my local clone of the Jupyter4Science/jupyter-mentor) repository. This results in a local Docker image I can then push to my DockerHub account.
This solution may have to be "good enough".
What has not worked for me
Ideally, I'd like to get this working from github actions so I don't have to do it locally, but as of today I'm not sure this is possible. I tried using the platform=linux/arm64
argument in repo2docker-action as such:
- name: update jupyter dependencies with repo2docker
uses: jupyterhub/repo2docker-action@master
with:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
REPO2DOCKER_EXTRA_ARGS: --Repo2Docker.platform=linux/arm64
but on the update jupyter dependencies with repo2docker
step of the action I received and error because the image platform doesn't match the host platform:
Step 2/50 : ENV DEBIAN_FRONTEND=noninteractive
Warning: rning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
---> Running in b74454c1f2a4
Removing intermediate container b74454c1f2a4
---> ad1affe2197d
Step 3/50 : RUN apt-get -qq update && apt-get -qq install --yes --no-install-recommends locales > /dev/null && apt-get -qq purge && apt-get -qq clean && rm -rf /var/lib/apt/lists/*
Warning: rning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
---> Running in abe671557370
exec /bin/sh: exec format error
In attempt to resolve this error, I tried running the action on macos-14 but that isn't currently supported by repo2docker.