Skip to content

Commit

Permalink
push-container: Also inject base-container into meta.json
Browse files Browse the repository at this point in the history
While I am trying to actively sever the dependence of the base
container image build on `meta.json`, there's no reason not
to inject it into `meta.json` in this flow too because the build
system already requires it.
  • Loading branch information
cgwalters committed Jun 8, 2022
1 parent b43bc2f commit 92195a6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions src/cmd-push-container
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import argparse
import json
import os
import tempfile
import shutil
import subprocess
import sys

Expand Down Expand Up @@ -49,6 +51,17 @@ if ":" not in container_name:
container_name = f"{container_name}:{latest_build}-{arch}"
if args.base_image_name:
container_name = f"{container_name}-base-image"
skopeoargs.extend([f"oci-archive:{ociarchive}", f"docker://{container_name}"])
print(subprocess.list2cmdline(skopeoargs))
os.execvp('skopeo', skopeoargs)
with tempfile.NamedTemporaryFile(dir='tmp', prefix='push-container-digestfile') as df:
skopeoargs.append(f"--digestfile={df.name}")
skopeoargs.extend([f"oci-archive:{ociarchive}", f"docker://{container_name}"])
print(subprocess.list2cmdline(skopeoargs))
subprocess.check_call(skopeoargs)
df.seek(0)
digest = df.read().decode('utf-8').strip()
# Inject the oscontainer with SHA256 into the build metadata
meta['base-oscontainer'] = {'image': container_name,
'digest': digest}
metapath_new = f"{metapath}.new"
with open(metapath_new, 'w') as f:
json.dump(meta, f, sort_keys=True)
shutil.move(metapath_new, metapath)

0 comments on commit 92195a6

Please sign in to comment.