Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Initialize docker cache in build.py for docker-compose containers (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
leezu committed Jul 16, 2020
1 parent 37bdf0b commit 2abf0b8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ci/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,17 @@ def list_platforms() -> str:
return "\nSupported platforms:\n{}".format('\n'.join(get_platforms()))


def load_docker_cache(tag, docker_registry) -> None:
def load_docker_cache(platform, tag, docker_registry) -> None:
"""Imports tagged container from the given docker registry"""
if docker_registry:
if platform in DOCKER_COMPOSE_WHITELIST:
env = os.environ.copy()
env["DOCKER_CACHE_REGISTRY"] = docker_registry
cmd = ['docker-compose', '-f', 'docker/docker-compose.yml', 'pull', platform]
logging.info("Running command: 'DOCKER_CACHE_REGISTRY=%s %s'", docker_registry, ' '.join(cmd))
check_call(cmd, env=env)
return

# noinspection PyBroadException
try:
import docker_cache
Expand Down Expand Up @@ -398,7 +406,7 @@ def main() -> int:
platform = args.platform
tag = get_docker_tag(platform=platform, registry=args.docker_registry)
if args.docker_registry and not args.no_pull:
load_docker_cache(tag=tag, docker_registry=args.docker_registry)
load_docker_cache(platform=platform, tag=tag, docker_registry=args.docker_registry)
if not args.run_only:
build_docker(platform=platform, registry=args.docker_registry, num_retries=args.docker_build_retries,
no_cache=args.no_cache, cache_intermediate=args.cache_intermediate)
Expand Down Expand Up @@ -442,7 +450,7 @@ def main() -> int:
logging.info("Artifacts will be produced in the build/ directory.")
for platform in platforms:
tag = get_docker_tag(platform=platform, registry=args.docker_registry)
load_docker_cache(tag=tag, docker_registry=args.docker_registry)
load_docker_cache(platform=platform, tag=tag, docker_registry=args.docker_registry)
build_docker(platform, registry=args.docker_registry, num_retries=args.docker_build_retries,
no_cache=args.no_cache)
if args.build_only:
Expand Down

0 comments on commit 2abf0b8

Please sign in to comment.