Skip to content

Commit

Permalink
apps: Fetch app images if sbom is turned off
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Sul <mike.sul@foundries.io>
  • Loading branch information
mike-sul committed Jun 4, 2024
1 parent 135f479 commit 9ccbcd6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ done

if [ -z "$DISABLE_SBOM" ] ; then
PYTHONPATH=${HERE}/.. python3 ${HERE}/generate_non_factory_sboms.py --arch=$ARCH
else
PYTHONPATH="${HERE}"/.. python3 "${HERE}"/fetch_app_images.py --apps-root "${REPO_ROOT}" --tag "${TAG}-${ARCH}"
fi
# 1. Parse the local docker store (the one where the built images are stored).
# 2. Extract layers metadata (size, usage) of all Apps' images
Expand Down
41 changes: 41 additions & 0 deletions apps/fetch_app_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import argparse
import logging
import os
import subprocess

from apps.compose_apps import ComposeApps
from apps.apps_publisher import AppsPublisher
from helpers import status


def main(args):
status("Fetching app images to the local docker engine store")

publisher = AppsPublisher(args.factory, "", "")
apps = ComposeApps(args.apps_root, quiet=True)
publisher.tag(apps, args.tag)
for app in apps:
subprocess.check_call(["docker", "compose", "--project-directory", app.dir, "pull"])


def get_args():
factory = os.environ.get("FACTORY")
arch = os.environ.get("ARCH")
parser = argparse.ArgumentParser("Pull app images into a local docker store")
parser.add_argument("--factory", default=factory)
parser.add_argument("--apps-root", default="./")
parser.add_argument("--tag", required=True)
parser.add_argument("--arch", default=arch)
args = parser.parse_args()
return args


if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s %(levelname)s: %(module)s: %(message)s', level=logging.INFO)
args = get_args()

# FACTORY must be set so that expandvars above will work correctly for
# service images like: hub.foundries.io/${FACTORY}/foo
os.environ["FACTORY"] = args.factory
main(args)

0 comments on commit 9ccbcd6

Please sign in to comment.