diff --git a/lib/tamarin.py b/lib/tamarin.py index 051890e..a19a689 100644 --- a/lib/tamarin.py +++ b/lib/tamarin.py @@ -12,6 +12,9 @@ def run_profile_hooks(profile, step, **kwargs): hook_path = os.path.join(hooks_dir, trimmed_hook_name) run([hook_path], **kwargs) +def get_base_dir(): + return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/..") + def get_hooks_dir(): return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../hooks") diff --git a/package b/package index 7eb4360..64c88c4 100755 --- a/package +++ b/package @@ -23,13 +23,16 @@ def create_args_parser(): parser.add_argument("--cleanup", help="Clear the workspace and remove obsolete Docker images before build", action="store_true", default=False) parser.add_argument("--override-docker-args", help="Override all 'docker run' arguments. Use '[IMAGE_TAG]', '[PROFILE]' and '[ARCH]' to insert the corresponding values into your command.", default="") parser.add_argument("--prepare-only", help="Only prepare build environment for the given profile", action="store_true", default=False) + parser.add_argument("--no-lib-mounts", help="Disable Tamarin library volumes mount", action="store_true", default=False) return parser def build_image(build_workspace, base_image, profile_name, profile, debug=False, rebuild=False): + shutil.copytree(tamarin.get_base_dir(), os.path.join(build_workspace, '.tamarin')) with open("{:s}/Dockerfile".format(build_workspace), 'w') as dockerfile: dockerfile.write("FROM {:s}\n".format(base_image)) + dockerfile.write("COPY .tamarin /tamarin\n") # Configure "containerbuild" hooks environment hooks_env = os.environ.copy() @@ -107,12 +110,16 @@ if __name__ == "__main__": docker_args += [ "-v", "{:s}:/src:ro".format(project_dir), "-v", "{:s}:/dist".format(output_dir), - "-v", "{:s}:/tamarin/hooks:ro".format(tamarin.get_hooks_dir()), - "-v", "{:s}:/tamarin/lib:ro".format(tamarin.get_lib_dir()), - "-v", "{:s}:/tamarin/profiles:ro".format(tamarin.get_profiles_dir()), - "-v", "{:s}:/tamarin/utils:ro".format(tamarin.get_utils_dir()) ] + if not args.no_lib_mounts: + docker_args += [ + "-v", "{:s}:/tamarin/hooks:ro".format(tamarin.get_hooks_dir()), + "-v", "{:s}:/tamarin/lib:ro".format(tamarin.get_lib_dir()), + "-v", "{:s}:/tamarin/profiles:ro".format(tamarin.get_profiles_dir()), + "-v", "{:s}:/tamarin/utils:ro".format(tamarin.get_utils_dir()) + ] + # Use environment proxy if defined for proxy_var in ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy']: if proxy_var in os.environ: