Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi-arch docker images #399

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

yuvipanda
Copy link
Member

@yuvipanda yuvipanda commented Oct 19, 2022

  • Install appropriate version of mambaforge based on build architecture
  • Generate lockfiles for arm64, amd64 and ppc64le

Ref #396

@github-actions
Copy link
Contributor

Binder 👈 Try on Mybinder.org!
Binder 👈 Try on Pangeo GCP Binder!
Binder 👈 Try on Pangeo AWS Binder!

The version of mambaforge appropriate for the architecture that
the docker build is running on is built this way.

Ref pangeo-data#396
@yuvipanda
Copy link
Member Author

conda-lock also needs to know though.

@yuvipanda yuvipanda marked this pull request as draft October 19, 2022 03:24
@yuvipanda
Copy link
Member Author

/condalock

@yuvipanda yuvipanda changed the title Don't hardcode CPU architecture in dockerfile Add support for multi-arch docker images Oct 19, 2022
- name: Specify which architectures to build lockfiles for
run: |
# space delimited list of architectures to send to conda-lock
echo "BUILD_ARCHS='64 aarch64 ppc64le'" > ${GITHUB_ENV}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it'd be best to just start with one additional? aarch64 and add others down the line if need be

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottyhq yeah i agree I mostly added both to test what packages are needed to be fixed for ppc64le

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's build just for linux-aarch64 first as mentioned at #396 (comment)

conda-lock lock --mamba -k explicit -f environment.yml -p linux-64
../generate-packages-list.py conda-linux-64.lock > packages.txt
for ARCH in ${BUILD_ARCHS}; do
conda-lock lock --mamba -k explicit -f environment.yml -p linux-${ARCH}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be a good time to switch to a unified lockfile and actually add conda-lock to the base environment. (Our current usage of conda-lock pre-dates the unified lockfile format now shown here https://github.com/conda-incubator/conda-lock#basic-usage). Installing the environment with conda-lock would actually recognize the host platform and choose the correct set of packages:

conda-lock lock -f environment.yml -p linux-64 aarch64
conda-lock install -n pangeo-notebook

the drawback is that if someone just has conda or mamba installed they dont recognize the new unified lockfile format... so you could not do conda env create -f conda-lock.yml ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottyhq ok that's pretty cool and we clearly should just move to that.

Copy link
Member

@weiji14 weiji14 Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking that we might need to update from conda-lock=1.4 to conda-lock=2.x first at

Also FYI, mamba doesn't support installing from the unified conda-lock.yml, but micromamba does according to https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html#conda-lock-yaml-spec-files. See also mamba-org/mamba#1884 (comment)

conda-lock lock --mamba -k explicit -f environment.yml -p linux-aarch64; \
../generate-packages-list.py conda-linux-aarch64.lock > packages-aarch64.txt; \
conda-lock lock --mamba -k explicit -f environment.yml -p linux-ppc64le; \
../generate-packages-list.py conda-linux-ppc64le.lock > packages-ppc64le.txt; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above on unified lockfile. but i still really like a simple text file as well though! maybe we create a artifacts subdirectory to organize files not actually used by docker build?

conda-lock lock --mamba -k explicit -f environment.yml -f ../pangeo-notebook/environment.yml -f ../base-notebook/environment.yml -p linux-aarch64; \
../generate-packages-list.py conda-linux-aarch64.lock > packages-aarch64.txt; \
conda-lock lock --mamba -k explicit -f environment.yml -f ../pangeo-notebook/environment.yml -f ../base-notebook/environment.yml -p linux-ppc64le; \
../generate-packages-list.py conda-linux-ppc64le.lock > packages-ppc64le.txt; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I have rarely used this Makefile and am always just building things via GitHub Actions ;) I've put in a little more time to embracing docker buildx and think it might be the right tool to evolve this repo. in particular the bake tool for several related images https://github.com/scottyhq/pangeo-buildx#usage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottyhq I completely agree - I love that repo and think that's what this should be :D What do you think needs to happen to complete that transition?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Mainly just more time :) I abandoned it for a bit with the "dont fix what isn't broken" rationale :) but it's also nice to keep evolving so I'll try to open a PR here this week and would love your review

@weiji14 weiji14 linked an issue Jun 27, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Images availability for OS/ARCH other than linux/amd64
4 participants