diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 597b4bfb..14b88ff0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: username: nextstrain-bot password: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_MANAGE_PACKAGES }} - - run: ./devel/build -r ghcr.io -t $TAG + - run: ./devel/build -p linux/amd64 -r ghcr.io -t $TAG outputs: tag: ${{ env.TAG }} diff --git a/README.md b/README.md index 3112d46f..c2179e9f 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,16 @@ To build this image locally, ./devel/build ``` - By default, this tags the image with `latest` and pushes to + By default, this builds for a single platform `linux/amd64`, tags the image with `latest`, and pushes to `localhost:5000`. See instructions at the top of the script for additional options. + If the target platform is different from the build platform, set up emulation before running `./devel/build`. This can be achieved using [`tonistiigi/binfmt`](https://github.com/tonistiigi/binfmt). For example, to set up emulation for `linux/arm64`, run: + + ``` + docker run --privileged --rm tonistiigi/binfmt --install arm64 + ``` + On each subsequent change during your development iterations, you can run just the `./devel/build` command again. diff --git a/devel/build b/devel/build index 11235bda..58a6dc4d 100755 --- a/devel/build +++ b/devel/build @@ -14,15 +14,17 @@ set -euo pipefail # Set default values. +platform=linux/amd64 registry=localhost:5000 tag=latest # Read command-line arguments. -while getopts "r:t:" opt; do +while getopts "p:r:t:" opt; do case "$opt" in + p) platform="$OPTARG";; r) registry="$OPTARG";; t) tag="$OPTARG";; - *) echo "Usage: $0 [-r ] [-t ]" 1>&2; exit 1;; + *) echo "Usage: $0 [-p ] [-r ] [-t ]" 1>&2; exit 1;; esac done @@ -36,8 +38,6 @@ export GIT_REVISION=$(git describe --tags --abbrev=40 --always --dirty || true) # Calling `docker run nextstrain/base` will still only pull down the small base # image rather than pulling down the larger nextstrain/base-builder image. -platform=linux/amd64 - # `buildx create` is necessary to use a driver that supports multi-platform # images. builder=nextstrain-builder