Skip to content

Commit f8c5b36

Browse files
authored
Merge pull request #33673 from def-/pr-push-ghcr
builds: Push to GHCR in parallel & pull from GHCR in CI
2 parents de93981 + c82d6a7 commit f8c5b36

File tree

13 files changed

+52
-14
lines changed

13 files changed

+52
-14
lines changed

bin/ci-builder

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ build() {
125125
--build-arg "RUST_CPU_TARGET=$rust_cpu_target" \
126126
--build-arg "RUST_TARGET_FEATURES=$rust_target_features" \
127127
--tag materialize/ci-builder:"$tag" \
128+
--tag ghcr.io/materializeinc/materialize/ci-builder:"$tag" \
128129
--tag materialize/ci-builder:"$cache_tag" \
129130
--target $docker_target \
130131
"$@" ci/builder
@@ -165,21 +166,24 @@ print(hash.decode())
165166
')
166167
cache_tag=cache-$flavor-$rust_version-$arch_go
167168

169+
image_registry="materialize"
170+
if is_truthy "${CI:-0}" || is_truthy "${MZ_GHCR:-0}"; then
171+
image_registry="ghcr.io/materializeinc/materialize"
172+
fi
168173

169174
case "$cmd" in
170175
build)
171176
build "$@"
172177
;;
173178
exists)
174-
docker manifest inspect materialize/ci-builder:"$tag" &> /dev/null
179+
docker manifest inspect "$image_registry"/ci-builder:"$tag" &> /dev/null
175180
;;
176181
tag)
177182
echo "$tag"
178183
;;
179184
push)
180-
build "$@"
181-
docker push materialize/ci-builder:"$tag"
182-
docker push materialize/ci-builder:"$cache_tag"
185+
docker login ghcr.io -u materialize-bot --password "$GITHUB_GHCR_TOKEN"
186+
build --push "$@"
183187
;;
184188
run)
185189
docker_command=()
@@ -239,6 +243,7 @@ case "$cmd" in
239243
--env AZURE_SERVICE_ACCOUNT_TENANT
240244
--env GCP_SERVICE_ACCOUNT_JSON
241245
--env GITHUB_TOKEN
246+
--env GITHUB_GHCR_TOKEN
242247
--env GPG_KEY
243248
--env LAUNCHDARKLY_API_TOKEN
244249
--env LAUNCHDARKLY_SDK_KEY
@@ -383,7 +388,7 @@ case "$cmd" in
383388
args+=(--volume "$GIT_ROOT_DIR:$GIT_ROOT_DIR")
384389
fi
385390
rm -f "$cid_file"
386-
docker run "${args[@]}" "materialize/ci-builder:$tag" eatmydata "${docker_command[@]}"
391+
docker run "${args[@]}" "$image_registry/ci-builder:$tag" eatmydata "${docker_command[@]}"
387392
;;
388393
root-shell)
389394
docker exec --interactive --tty --user 0:0 "$(<"$cid_file")" eatmydata ci/builder/root-shell.sh

ci/builder/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ RUN curl -fsSL https://amazon-inspector-sbomgen.s3.amazonaws.com/1.8.1/linux/$AR
345345

346346
# Hardcode some known SSH hosts, or else SSH will ask whether the host is
347347
# trustworthy on the first connection.
348-
349348
COPY ssh_known_hosts /etc/ssh/ssh_known_hosts
350349

351350
ENV LDFLAGS="-fuse-ld=lld -static-libstdc++"
@@ -356,7 +355,7 @@ ENV CARGO_INCREMENTAL=1
356355
ENV HELM_PLUGINS=/usr/local/share/helm/plugins
357356

358357
# Set up for a persistent volume to hold Cargo metadata, so that crate metadata
359-
# does not need to be refetched on every compile.
358+
# does not need to be refetched on every compilation.
360359
ENV CARGO_HOME=/cargo
361360
RUN mkdir /cargo && chmod 777 /cargo
362361
VOLUME /cargo

ci/deploy/docker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ def main() -> None:
3030
Arch.X86_64,
3131
coverage=False,
3232
sanitizer=Sanitizer.none,
33+
image_registry="materialize",
3334
),
3435
mzbuild.Repository(
3536
Path("."),
3637
Arch.AARCH64,
3738
coverage=False,
3839
sanitizer=Sanitizer.none,
40+
image_registry="materialize",
3941
),
4042
]
4143
buildkite_tag = os.environ["BUILDKITE_TAG"]

ci/deploy_mz-debug/linux.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def main() -> None:
2323
Path("."),
2424
coverage=False,
2525
sanitizer=Sanitizer.none,
26+
image_registry="materialize",
2627
)
2728
target = f"{repo.rd.arch}-unknown-linux-gnu"
2829

ci/deploy_mz/docker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ def main() -> None:
2424
Arch.X86_64,
2525
coverage=False,
2626
sanitizer=Sanitizer.none,
27+
image_registry="materialize",
2728
),
2829
mzbuild.Repository(
2930
Path("."),
3031
Arch.AARCH64,
3132
coverage=False,
3233
sanitizer=Sanitizer.none,
34+
image_registry="materialize",
3335
),
3436
]
3537

ci/deploy_mz/linux.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def main() -> None:
2424
Path("."),
2525
coverage=False,
2626
sanitizer=Sanitizer.none,
27+
image_registry="materialize",
2728
)
2829
target = f"{repo.rd.arch}-unknown-linux-gnu"
2930

ci/deploy_mz_lsp_server/linux.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def main() -> None:
2525
Path("."),
2626
coverage=False,
2727
sanitizer=Sanitizer.none,
28+
image_registry="materialize",
2829
)
2930
target = f"{repo.rd.arch}-unknown-linux-gnu"
3031

ci/test/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def main() -> None:
3232
Path("."),
3333
coverage=coverage,
3434
sanitizer=sanitizer,
35+
image_registry="materialize",
3536
)
3637

3738
# Build and push any images that are not already available on Docker Hub,

ci/test/dev_tag.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ def main() -> None:
2727
Arch.X86_64,
2828
coverage=False,
2929
sanitizer=sanitizer,
30+
image_registry="materialize",
3031
),
3132
mzbuild.Repository(
3233
Path("."),
3334
Arch.AARCH64,
3435
coverage=False,
3536
sanitizer=sanitizer,
37+
image_registry="materialize",
3638
),
3739
]
3840
print("--- Tagging development Docker images")

misc/images/ubuntu-base/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ENV RUST_BACKTRACE=1
1717
ENV RUST_LIB_BACKTRACE=0
1818

1919
ARG BUILD_PROFILE=optimize
20+
2021
LABEL build.profile=$BUILD_PROFILE
2122

2223
RUN sed -i -e 's#http://archive\.ubuntu\.com#http://us-east-1.ec2.archive.ubuntu.com#' \

0 commit comments

Comments
 (0)