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

Revert "build: Use different cache and output registries" #155

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ concurrency:
cancel-in-progress: true

jobs:
# Build multi-platform builder and final images with caching from Docker Hub;
# push to GitHub Container Registry.
# Build multi-platform builder and final images with caching from Docker Hub
# and GitHub Container Registry; push to GitHub Container Registry.
build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
username: nextstrain-bot
password: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_MANAGE_PACKAGES }}

- run: ./devel/build -p linux/amd64,linux/arm64 -c docker.io -o ghcr.io -t $TAG
- run: ./devel/build -p linux/amd64,linux/arm64 -r ghcr.io -t $TAG

outputs:
tag: ${{ env.TAG }}
Expand Down
33 changes: 15 additions & 18 deletions devel/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
# Builds the nextstrain/base and nextstrain/base-builder images with useful
# caching and pushes to a registry.
#
# By default this tags images using "latest" and pushes to localhost:5000 with
# same-registry caching, but you can provide a custom tag with -t <tag> and
# specify different registries with -o <output_registry> and
# -c <cache_registry>.
# By default this tags images using "latest" and pushes to localhost:5000, but
# you can provide a custom tag with -t <tag> and specify a different
# registry with -r <registry>.
#
# Set CACHE_DATE in your environment to force layers after our custom cache
# point to be re-built. See the ARG CACHE_DATE line in the Dockerfile for more
Expand All @@ -16,18 +15,16 @@ set -euo pipefail

# Set default values.
platform=linux/amd64
cache_registry=localhost:5000
output_registry=localhost:5000
registry=localhost:5000
tag=latest

# Read command-line arguments.
while getopts "p:c:o:t:" opt; do
while getopts "p:r:t:" opt; do
case "$opt" in
p) platform="$OPTARG";;
c) cache_registry="$OPTARG";;
o) output_registry="$OPTARG";;
r) registry="$OPTARG";;
t) tag="$OPTARG";;
*) echo "Usage: $0 [-p <platform>] [-c <cache_registry>] [-o <output_registry>] [-t <tag>]" 1>&2; exit 1;;
*) echo "Usage: $0 [-p <platform>] [-r <registry>] [-t <tag>]" 1>&2; exit 1;;
esac
done

Expand Down Expand Up @@ -63,10 +60,10 @@ docker buildx build \
--build-arg CACHE_DATE \
--cache-from "$BUILDER_IMAGE:latest" \
--cache-from "$BUILDER_IMAGE:$tag" \
--cache-from "$cache_registry/$BUILDER_IMAGE:latest" \
--cache-from "$cache_registry/$BUILDER_IMAGE:$tag" \
--cache-from "$registry/$BUILDER_IMAGE:latest" \
--cache-from "$registry/$BUILDER_IMAGE:$tag" \
--cache-to type=inline \
--tag "$output_registry/$BUILDER_IMAGE:$tag" \
--tag "$registry/$BUILDER_IMAGE:$tag" \
--push \
--provenance false \
.
Expand All @@ -80,12 +77,12 @@ docker buildx build \
--cache-from "$BUILDER_IMAGE:$tag" \
--cache-from "$FINAL_IMAGE:latest" \
--cache-from "$FINAL_IMAGE:$tag" \
--cache-from "$cache_registry/$BUILDER_IMAGE:latest" \
--cache-from "$cache_registry/$BUILDER_IMAGE:$tag" \
--cache-from "$cache_registry/$FINAL_IMAGE:latest" \
--cache-from "$cache_registry/$FINAL_IMAGE:$tag" \
--cache-from "$registry/$BUILDER_IMAGE:latest" \
--cache-from "$registry/$BUILDER_IMAGE:$tag" \
--cache-from "$registry/$FINAL_IMAGE:latest" \
--cache-from "$registry/$FINAL_IMAGE:$tag" \
--cache-to type=inline \
--tag "$output_registry/$FINAL_IMAGE:$tag" \
--tag "$registry/$FINAL_IMAGE:$tag" \
--push \
--provenance false \
.