Skip to content

Commit

Permalink
Use buildx create+build
Browse files Browse the repository at this point in the history
This makes it easier to support multi-platform builds in the future, and
explicitly sets the currently used platform (linux/amd64).

Note that --load is only available for single-platform builds. Will
need to adjust this for future multi-platform builds.

Co-authored-by: Thomas Sibley <[email protected]>
  • Loading branch information
victorlin and tsibley authored Jul 16, 2022
1 parent b30b5e8 commit fac834e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions devel/build
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,37 @@ 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.

docker build \
platform=linux/amd64

# `buildx create` is necessary to use a driver that supports multi-platform
# images.
builder=nextstrain-builder

if ! docker buildx inspect "$builder" &>/dev/null; then
docker buildx create --name "$builder" --driver docker-container
fi

docker buildx build \
--builder "$builder" \
--platform $platform \
--build-arg CACHE_DATE \
--build-arg GIT_REVISION \
--cache-from nextstrain/base-builder \
--cache-from nextstrain/base \
--cache-to type=inline \
--tag nextstrain/base-builder \
--load \
--target builder \
.

docker build \
docker buildx build \
--builder "$builder" \
--platform $platform \
--build-arg CACHE_DATE \
--build-arg GIT_REVISION \
--cache-from nextstrain/base-builder \
--cache-from nextstrain/base \
--cache-to type=inline \
--tag nextstrain/base \
--load \
.

0 comments on commit fac834e

Please sign in to comment.