Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions jetson_containers/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Container build system for managing package configurations and multi-stage build chains, with automated testing and dependency tracking.
# Container build system for managing package configurations and multi-stage build chains, with automated testing and dependency tracking.
#
# A "package" is composed of a Dockerfile, configs, and test scripts. These are found under the jetson-containers/packages directory.
# There are also "meta-packages" that have no Dockerfiles themselves, but specify a set of packages to include (e.g. l4t-pytorch)
Expand All @@ -12,9 +12,9 @@
# Some example build scenarios:
#
# $ jetson-containers/build.sh --name=xyz pytorch jupyterlab # build container with PyTorch and JupyterLab server
# $ jetson-containers/build.sh --multiple pytorch tensorflow # build separate containers for PyTorch and
# $ jetson-containers/build.sh --multiple pytorch tensorflow # build separate containers for PyTorch and
# $ jetson-containers/build.sh --multiple ros:humble* # build all ROS Humble containers (can use wildcards)
# $ jetson-containers/build.sh ros:humble-desktop pytorch # build ROS Humble with PyTorch on top
# $ jetson-containers/build.sh ros:humble-desktop pytorch # build ROS Humble with PyTorch on top
# $ jetson-containers/build.sh --base=xyz:latest pytorch # add PyTorch to an existing container
#
# Typically the jetson-containers/build.sh wrapper script is used to launch this underlying Python module. jetson-containers can also
Expand All @@ -32,7 +32,7 @@
)

parser = argparse.ArgumentParser()

parser.add_argument('packages', type=str, nargs='*', default=[], help='packages or containers to build (filterable by wildcards)')

parser.add_argument('--name', type=str, default='', help="the name of the output container to build")
Expand All @@ -57,15 +57,18 @@
parser.add_argument('--version', action='store_true', help="print platform version info and exit")
parser.add_argument('--no-github-api', action='store_true', help="disalbe Github API use to force rebuild on new git commits")

parser.add_argument('--build-network', type=str, default='host', help="Docker network mode to use during build (default: host)")
parser.add_argument('--test-network', type=str, default='host', help="Docker network mode to use during test phase (default: host)")

args = parser.parse_args()

# validate args
if args.skip_errors and not args.multiple:
raise ValueError("--skip-errors can only be used with --multiple flag")

if args.verbose:
os.environ['VERBOSE'] = 'ON'

# split multi-value keyword arguments
args.package_dirs = re.split(',|;|:', args.package_dirs)
args.skip_packages = re.split(',|;|:', args.skip_packages)
Expand Down Expand Up @@ -103,23 +106,27 @@
# set logging directories
if args.logs:
set_log_dir(args.logs)

# list/show package info
if args.list_packages or args.show_packages:
packages = find_packages(args.packages, skip=args.skip_packages)

if args.list_packages:
for package in sorted(packages.keys()):
print(package)

if args.show_packages:
pprint.pprint(packages)

sys.exit(0)

# build one multi-stage container from chain of packages
# or launch multiple independent container builds
if not args.multiple:
build_container(args.name, args.packages, args.base, args.build_flags, args.build_args, args.simulate, args.skip_tests, args.test_only, args.push, args.no_github_api, args.skip_packages)
else:
build_containers(args.name, args.packages, args.base, args.build_flags, args.build_args, args.simulate, args.skip_errors, args.skip_packages, args.skip_tests, args.test_only, args.push)
build_container(args.name, args.packages, args.base, args.build_flags, args.build_args, args.simulate, args.skip_tests, args.test_only, args.push, args.no_github_api, args.skip_packages,
build_network=args.build_network,
test_network=args.test_network )
else:
build_containers(args.name, args.packages, args.base, args.build_flags, args.build_args, args.simulate, args.skip_errors, args.skip_packages, args.skip_tests, args.test_only, args.push,
build_network=args.build_network,
test_network=args.test_network )
Loading