Skip to content

Commit da1115a

Browse files
[ci] Mirror third-party images and hailgenetics images on deploy (#12818)
- On *deploys*, makes sure that whatever is in our third-party images is in our private registry before starting builds like hail-ubuntu that might depend on those images. This means that we can update our ubuntu base image without the australians needing to deploy any images by hand. However, this does not run in PRs because I 1) didn't want to add that kind of latency for PRs and 2) we don't do any kind of namespacing for our images so if we did include this for a PR that ultimately wasn't merged we would have to manually remove the image anyway so why not manually add it if you're going to PR it… I think point 2 is a little weak but I recall this being what we agreed on a couple months back when we discussed this. I'm wondering if we should just eat the minute or so latency at the beginning of PRs to be safe but it also feels like a shame for something that changes so infrequently. - Again on deploys, upload the hailgenetics/* images to the private registry if they don't already exist there. This way any deployments that aren't hail team's GCP deployment can get these images automatically when they deploy a new SHA instead of uploading them manually. It won't backfill skipped versions, but we decided that was ok. This seems less relevant for testing on PRs as it will get triggered on releases and we can easily dev deploy to rectify the image if this breaks.
1 parent 39b1606 commit da1115a

File tree

3 files changed

+111
-15
lines changed

3 files changed

+111
-15
lines changed

build.yaml

+95-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ steps:
3333
to: /git_version
3434
dependsOn:
3535
- git_make_bash_image
36-
- kind: buildImage2
37-
name: hail_ubuntu_image
38-
dockerFile: /io/hail-ubuntu/Dockerfile
39-
contextPath: /io/hail-ubuntu
40-
publishAs: hail-ubuntu
41-
resources:
42-
storage: 10Gi
43-
cpu: "2"
44-
memory: standard
45-
inputs:
46-
- from: /repo/docker/hail-ubuntu
47-
to: /io/hail-ubuntu
48-
dependsOn:
49-
- merge_code
5036
- kind: createNamespace
5137
name: default_ns
5238
namespaceName: default
@@ -73,6 +59,55 @@ steps:
7359
- name: batch-worker-ssh-public-key
7460
clouds:
7561
- azure
62+
- kind: runImage
63+
name: copy_third_party_images
64+
image: quay.io/skopeo/stable:v1.11.1
65+
script: |
66+
set -ex
67+
68+
REGISTRY={{ global.docker_prefix.split('/')[0] }}
69+
70+
{% if global.cloud == "gcp" %}
71+
cat /registry-push-credentials/credentials.json | base64 -w 0 | skopeo login -u _json_key_base64 --password-stdin $REGISTRY
72+
{% elif global.cloud == "azure" %}
73+
dnf install -y jq
74+
USERNAME=$(cat /registry-push-credentials/credentials.json | jq -jr '.appId')
75+
cat /registry-push-credentials/credentials.json | jq -jr '.password' | skopeo login -u $USERNAME --password-stdin $REGISTRY
76+
{% else %}
77+
echo "unknown cloud {{ global.cloud }}"
78+
exit 1
79+
{% endif %}
80+
81+
cd /io/docker/third-party
82+
DOCKER_PREFIX={{ global.docker_prefix }} bash copy_images.sh
83+
inputs:
84+
- from: /repo/docker
85+
to: /io/docker
86+
secrets:
87+
- name: registry-push-credentials
88+
namespace:
89+
valueFrom: default_ns.name
90+
mountPath: /registry-push-credentials
91+
scopes:
92+
- deploy
93+
dependsOn:
94+
- default_ns
95+
- merge_code
96+
- kind: buildImage2
97+
name: hail_ubuntu_image
98+
dockerFile: /io/hail-ubuntu/Dockerfile
99+
contextPath: /io/hail-ubuntu
100+
publishAs: hail-ubuntu
101+
resources:
102+
storage: 10Gi
103+
cpu: "2"
104+
memory: standard
105+
inputs:
106+
- from: /repo/docker/hail-ubuntu
107+
to: /io/hail-ubuntu
108+
dependsOn:
109+
- merge_code
110+
- copy_third_party_images
76111
- kind: deploy
77112
name: deploy_batch_sa
78113
namespace:
@@ -655,6 +690,7 @@ steps:
655690
to: /io/repo/ci
656691
dependsOn:
657692
- merge_code
693+
- copy_third_party_images
658694
- kind: runImage
659695
name: build_hail_jar_and_wheel_only
660696
image:
@@ -1563,6 +1599,7 @@ steps:
15631599
- default_ns
15641600
- base_image
15651601
- create_certs
1602+
- copy_third_party_images
15661603
- kind: deploy
15671604
name: deploy_prometheus
15681605
namespace:
@@ -1574,6 +1611,7 @@ steps:
15741611
dependsOn:
15751612
- default_ns
15761613
- create_certs
1614+
- copy_third_party_images
15771615
- kind: runImage
15781616
name: create_dummy_oauth2_client_secret
15791617
image:
@@ -3141,6 +3179,49 @@ steps:
31413179
- make_docs
31423180
clouds:
31433181
- gcp
3182+
- kind: runImage
3183+
name: mirror_hailgenetics_images
3184+
image: quay.io/skopeo/stable:v1.11.1
3185+
script: |
3186+
set -ex
3187+
3188+
REGISTRY={{ global.docker_prefix.split('/')[0] }}
3189+
3190+
set +x
3191+
{% if global.cloud == "gcp" %}
3192+
cat /registry-push-credentials/credentials.json | base64 -w 0 | skopeo login -u _json_key_base64 --password-stdin $REGISTRY
3193+
{% elif global.cloud == "azure" %}
3194+
dnf install -y jq
3195+
USERNAME=$(cat /registry-push-credentials/credentials.json | jq -jr '.appId')
3196+
cat /registry-push-credentials/credentials.json | jq -jr '.password' | skopeo login -u $USERNAME --password-stdin $REGISTRY
3197+
{% else %}
3198+
echo "unknown cloud {{ global.cloud }}"
3199+
exit 1
3200+
{% endif %}
3201+
set -x
3202+
3203+
cd /io/docker/hailgenetics
3204+
export HAIL_PIP_VERSION=$(cat /io/hail_pip_version)
3205+
export DOCKER_PREFIX={{ global.docker_prefix }}
3206+
bash mirror_images.sh
3207+
inputs:
3208+
- from: /hail_pip_version
3209+
to: /io/hail_pip_version
3210+
- from: /repo/docker/hailgenetics/mirror_images.sh
3211+
to: /io/docker/hailgenetics/mirror_images.sh
3212+
- from: /repo/docker/copy_image.sh
3213+
to: /io/docker/copy_image.sh
3214+
secrets:
3215+
- name: registry-push-credentials
3216+
namespace:
3217+
valueFrom: default_ns.name
3218+
mountPath: /registry-push-credentials
3219+
scopes:
3220+
- deploy
3221+
- dev
3222+
dependsOn:
3223+
- default_ns
3224+
- merge_code
31443225
- kind: buildImage2
31453226
name: website_image
31463227
dockerFile: /io/repo/website/Dockerfile

docker/copy_image.sh

100644100755
File mode changed.

docker/hailgenetics/mirror_images.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ set -ex
44

55
source ../copy_image.sh
66

7+
copy_if_not_present() {
8+
src_image=$1
9+
dest_image=$2
10+
if ! skopeo inspect "docker://docker.io/$1";
11+
then
12+
echo "$1 does not exist yet, doing nothing"
13+
elif skopeo inspect "docker://$2";
14+
then
15+
echo "$2 already exists, doing nothing"
16+
else
17+
echo "$2 does not exist, copying $1 to $2"
18+
copy_image $1 $2
19+
fi
20+
}
21+
722
if [[ -z "${DOCKER_PREFIX}" ]];
823
then
924
echo "Env variable DOCKER_PREFIX must be set"
@@ -30,5 +45,5 @@ images=(
3045
)
3146
for image in "${images[@]}"
3247
do
33-
copy_image "hailgenetics/${image}" "${DOCKER_PREFIX}/hailgenetics/${image}"
48+
copy_if_not_present "hailgenetics/${image}" "${DOCKER_PREFIX}/hailgenetics/${image}"
3449
done

0 commit comments

Comments
 (0)