Skip to content

Commit 3de02d1

Browse files
authored
Merge pull request #91: Name the final stage explicitly, move scripts, other minor refactoring
2 parents d9a8502 + 3d45a61 commit 3de02d1

6 files changed

Lines changed: 30 additions & 29 deletions

File tree

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ RUN pip3 install google-cloud-storage==2.1.0
8181
ARG CACHE_DATE
8282

8383
# Add helpers for build
84-
COPY devel/download-repo devel/latest-augur-release-tag /devel/
84+
COPY builder-scripts/download-repo builder-scripts/latest-augur-release-tag /builder-scripts/
8585

8686
# Fauna
87-
RUN /devel/download-repo https://github.com/nextstrain/fauna master /nextstrain/fauna
87+
RUN /builder-scripts/download-repo https://github.com/nextstrain/fauna master /nextstrain/fauna
8888

8989
# Augur
90-
RUN /devel/download-repo https://github.com/nextstrain/augur "$(/devel/latest-augur-release-tag)" /nextstrain/augur
90+
RUN /builder-scripts/download-repo https://github.com/nextstrain/augur "$(/builder-scripts/latest-augur-release-tag)" /nextstrain/augur
9191

9292
# Auspice
93-
RUN /devel/download-repo https://github.com/nextstrain/auspice release /nextstrain/auspice
93+
RUN /builder-scripts/download-repo https://github.com/nextstrain/auspice release /nextstrain/auspice
9494

9595
# Install Fauna deps
9696
RUN pip3 install --requirement=/nextstrain/fauna/requirements.txt
@@ -133,7 +133,7 @@ RUN cd /nextstrain/auspice && npm update && npm install && npm run build && npm
133133
# ———————————————————————————————————————————————————————————————————— #
134134

135135
# Now build the final image.
136-
FROM python:3.7-slim-buster
136+
FROM python:3.7-slim-buster AS final
137137

138138
# Add system runtime deps
139139
RUN apt-get update && apt-get install -y --no-install-recommends \

devel/build

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,33 @@ if ! docker buildx inspect "$builder" &>/dev/null; then
3939
docker buildx create --name "$builder" --driver docker-container
4040
fi
4141

42-
BASE_IMAGE="nextstrain/base"
43-
BASE_BUILDER_IMAGE="nextstrain/base-builder"
42+
BUILDER_IMAGE=nextstrain/base-builder
43+
FINAL_IMAGE=nextstrain/base
4444

4545
docker buildx build \
46+
--target builder \
4647
--builder "$builder" \
47-
--platform $platform \
48+
--platform "$platform" \
4849
--build-arg CACHE_DATE \
4950
--build-arg GIT_REVISION \
50-
--cache-from $BASE_BUILDER_IMAGE:latest \
51-
--cache-from $BASE_BUILDER_IMAGE:$tag \
51+
--cache-from "$BUILDER_IMAGE:latest" \
52+
--cache-from "$BUILDER_IMAGE:$tag" \
5253
--cache-to type=inline \
53-
--tag $BASE_BUILDER_IMAGE:$tag \
54+
--tag "$BUILDER_IMAGE:$tag" \
5455
--load \
55-
--target builder \
5656
.
5757

5858
docker buildx build \
59+
--target final \
5960
--builder "$builder" \
60-
--platform $platform \
61+
--platform "$platform" \
6162
--build-arg CACHE_DATE \
6263
--build-arg GIT_REVISION \
63-
--cache-from $BASE_BUILDER_IMAGE:latest \
64-
--cache-from $BASE_BUILDER_IMAGE:$tag \
65-
--cache-from $BASE_IMAGE:latest \
66-
--cache-from $BASE_IMAGE:$tag \
64+
--cache-from "$BUILDER_IMAGE:latest" \
65+
--cache-from "$BUILDER_IMAGE:$tag" \
66+
--cache-from "$FINAL_IMAGE:latest" \
67+
--cache-from "$FINAL_IMAGE:$tag" \
6768
--cache-to type=inline \
68-
--tag $BASE_IMAGE:$tag \
69+
--tag "$FINAL_IMAGE:$tag" \
6970
--load \
7071
.

devel/push

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ if [[ $# -eq 0 ]]; then
1414
set -- latest
1515
fi
1616

17-
BASE_IMAGE="nextstrain/base"
18-
BASE_BUILDER_IMAGE="nextstrain/base-builder"
17+
BUILDER_IMAGE=nextstrain/base-builder
18+
FINAL_IMAGE=nextstrain/base
1919

2020
for tag in "$@"; do
21-
if [[ $(docker image inspect --format "{{.RepoDigests}}" $BASE_IMAGE:$tag) != '[]' || $(docker image inspect --format "{{.RepoDigests}}" $BASE_BUILDER_IMAGE:$tag) != '[]' ]]; then
22-
echo "At least one of $BASE_IMAGE:$tag and $BASE_BUILDER_IMAGE:$tag has already been pushed. This can happen if the newly built image is not available in the local registry." >&2
21+
if [[ $(docker image inspect --format "{{.RepoDigests}}" $BUILDER_IMAGE:$tag) != '[]' || $(docker image inspect --format "{{.RepoDigests}}" $FINAL_IMAGE:$tag) != '[]' ]]; then
22+
echo "At least one of $BUILDER_IMAGE:$tag and $FINAL_IMAGE:$tag has already been pushed. This can happen if the newly built image is not available in the local registry." >&2
2323
exit 1
2424
fi
2525
done
2626

2727
for tag in "$@"; do
28-
docker push $BASE_BUILDER_IMAGE:$tag
29-
docker push $BASE_IMAGE:$tag
28+
docker push "$BUILDER_IMAGE:$tag"
29+
docker push "$FINAL_IMAGE:$tag"
3030
done

devel/tag-latest

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ if [[ $# -ne 1 ]]; then
1010
exit 1
1111
fi
1212

13-
tag=$1
13+
tag="$1"
1414

15-
BASE_IMAGE="nextstrain/base"
16-
BASE_BUILDER_IMAGE="nextstrain/base-builder"
15+
BUILDER_IMAGE=nextstrain/base-builder
16+
FINAL_IMAGE=nextstrain/base
1717

18-
docker tag $BASE_BUILDER_IMAGE:{$tag,latest}
19-
docker tag $BASE_IMAGE:{$tag,latest}
18+
docker tag "$BUILDER_IMAGE":{"$tag",latest}
19+
docker tag "$FINAL_IMAGE":{"$tag",latest}

0 commit comments

Comments
 (0)