Skip to content

Commit edce783

Browse files
jbtrystramravanelli
authored andcommitted
jobs/nodeimage: use the base image digest for FROM
Instead of relying on the tag of the base image, first grab the manifest digest than pass that value to the builders. This will avoid reusing stale images that may be present in the local containers storage when building. Co-authored-by: Renata Ravanelli <renata.ravanelli@gmail.com>
1 parent b72a322 commit edce783

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utils.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,16 @@ def delete_tags(digests, repo, manifest_tag, authfile = "") {
921921
}]}
922922
}
923923

924+
def get_manifest_digest(image) {
925+
if (image != '' && !image.contains('@')) {
926+
shwrap("skopeo inspect --raw -n docker://${image} > manifest.json")
927+
def digest = shwrapCapture("skopeo manifest-digest manifest.json")
928+
shwrap("rm -f manifest.json")
929+
image = "${image.split(':')[0]}@${digest}"
930+
}
931+
return image
932+
}
933+
924934
def build_and_push_image(params = [:]) {
925935
// Available parameters:
926936
// arches: list -- List of architectures to run against
@@ -940,6 +950,7 @@ def build_and_push_image(params = [:]) {
940950
def extra_build_args = params.get('extra_build_args', "");
941951
def v2s2 = params.get('v2s2', false);
942952

953+
from = get_manifest_digest(from)
943954
def digests = build_remote_image(params['arches'], params['src_commit'], params['src_url'], params['staging_repository'],
944955
params['image_tag_staging'], secret, from, extra_build_args)
945956
stage("Push Manifest") {

0 commit comments

Comments
 (0)