larroy closed pull request #13077: Add --no-cache option to build.py when 
building containers
URL: https://github.com/apache/incubator-mxnet/pull/13077
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ci/README.md b/ci/README.md
index 6c8a23f03cf..5b6cc668978 100644
--- a/ci/README.md
+++ b/ci/README.md
@@ -5,6 +5,8 @@ Docker containers
 
 You need docker and nvidia docker if you have a GPU.
 
+Also you need to run `pip3 install docker` as it uses the [docker python 
module](https://docker-py.readthedocs.io/en/stable/containers.html#)
+
 If you are in ubuntu an easy way to install Docker CE is executing the
 following script:
 
diff --git a/ci/build.py b/ci/build.py
index 8f3fe2d1244..fa764ad3f2d 100755
--- a/ci/build.py
+++ b/ci/build.py
@@ -112,7 +112,7 @@ def get_docker_binary(use_nvidia_docker: bool) -> str:
     return "nvidia-docker" if use_nvidia_docker else "docker"
 
 
-def build_docker(platform: str, docker_binary: str, registry: str, 
num_retries: int, use_cache: bool) -> str:
+def build_docker(platform: str, docker_binary: str, registry: str, 
num_retries: int, use_cache: bool, no_cache: bool) -> str:
     """
     Build a container for the given platform
     :param platform: Platform
@@ -144,8 +144,10 @@ def build_docker(platform: str, docker_binary: str, 
registry: str, num_retries:
            "-f", get_dockerfile(platform),
            "--build-arg", "USER_ID={}".format(os.getuid()),
            "--build-arg", "GROUP_ID={}".format(os.getgid())]
-    if use_cache:
+    if use_cache and not no_cache:
         cmd.extend(["--cache-from", tag])
+    if no_cache:
+        cmd.append("--no-cache")
     cmd.extend(["-t", tag, get_dockerfiles_path()])
 
     @retry(subprocess.CalledProcessError, tries=num_retries)
@@ -436,6 +438,9 @@ def main() -> int:
                         " to use local layers for caching. If absent, we use 
the cache from dockerhub"
                         " which is the default.")
 
+    parser.add_argument("--no-cache", action="store_true",
+                        help="passes --no-cache to docker build")
+
     parser.add_argument("command",
                         help="command to run in the container",
                         nargs='*', action='append', type=str)
@@ -475,7 +480,8 @@ def signal_handler(signum, _):
         if use_cache():
             load_docker_cache(tag=tag, docker_registry=args.docker_registry)
         build_docker(platform=platform, docker_binary=docker_binary, 
registry=args.docker_registry,
-                     num_retries=args.docker_build_retries, 
use_cache=use_cache())
+                     num_retries=args.docker_build_retries, 
use_cache=use_cache(),
+                     no_cache=args.no_cache)
         if args.build_only:
             logging.warning("Container was just built. Exiting due to 
build-only.")
             return 0
diff --git a/ci/requirements.txt b/ci/requirements.txt
new file mode 100644
index 00000000000..8f21ead27f7
--- /dev/null
+++ b/ci/requirements.txt
@@ -0,0 +1 @@
+docker==3.5.0


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to