From 2e3ec0cece1d8b78cf804890a17ae6b624d32a71 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Wed, 24 Jul 2024 01:51:50 +0300 Subject: [PATCH] Always bust builder cache building the container image Do not use by default the builder cache, when we build the Dangerzone container image. This way, we can always have the most fresh result when we run the `./install/common/build-image.py` command. If a dev wants to speed up non-release builds, we add the `--use-cache` flag to use the builder cache. --- install/common/build-image.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/install/common/build-image.py b/install/common/build-image.py index 23218bc..9f2dcc8 100644 --- a/install/common/build-image.py +++ b/install/common/build-image.py @@ -37,28 +37,36 @@ def main(): default=9, help="The Gzip compression level, from 0 (lowest) to 9 (highest, default)", ) + parser.add_argument( + "--use-cache", + action="store_true", + help="Use the builder's cache to speed up the builds (not suitable for release builds)", + ) args = parser.parse_args() print(f"Building for architecture '{ARCH}'") print("Exporting container pip dependencies") with ContainerPipDependencies(): - print("Pulling base image") - subprocess.run( - [ - args.runtime, - "pull", - "alpine:latest", - ], - check=True, - ) + if not args.use_cache: + print("Pulling base image") + subprocess.run( + [ + args.runtime, + "pull", + "alpine:latest", + ], + check=True, + ) print("Building container image") + cache_args = [] if args.use_cache else ["--no-cache"] subprocess.run( [ args.runtime, "build", BUILD_CONTEXT, + *cache_args, "--build-arg", f"REQUIREMENTS_TXT={REQUIREMENTS_TXT}", "--build-arg",