From 5c2d1b2fa94db878cdd022e643145f3053f48ea2 Mon Sep 17 00:00:00 2001 From: "Liu, Jianjun" Date: Mon, 17 Jun 2019 11:54:10 +0000 Subject: [PATCH] only copy delta files when multistage build For some Host OS configuration with redirect_dir on, extra data are saved on the upper layer when the same file exists on different layers. To minimize docker image size, remove the overlapped files before copy, when cgit, httpd, mariadb, memcached, nginx and postgres. Signed-off-by: Liu, Jianjun --- cgit/Dockerfile | 9 +++++++++ httpd/Dockerfile | 9 +++++++++ mariadb/Dockerfile | 9 +++++++++ memcached/Dockerfile | 9 +++++++++ nginx/Dockerfile | 9 +++++++++ postgres/Dockerfile | 9 +++++++++ 6 files changed, 54 insertions(+) diff --git a/cgit/Dockerfile b/cgit/Dockerfile index 6c97773..df59377 100644 --- a/cgit/Dockerfile +++ b/cgit/Dockerfile @@ -18,6 +18,15 @@ RUN source /os-release && \ --bundles=sudo,curl,scm-server --no-scripts \ && rm -rf /install_root/var/lib/swupd/* +# For some Host OS configuration with redirect_dir on, +# extra data are saved on the upper layer when the same +# file exists on different layers. To minimize docker +# image size, remove the overlapped files before copy. +RUN mkdir /os_core_install +COPY --from=clearlinux/os-core:latest / /os_core_install/ +RUN cd / && \ + find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true + FROM clearlinux/httpd:latest COPY --from=builder /install_root / diff --git a/httpd/Dockerfile b/httpd/Dockerfile index c89f589..b6f9b1b 100644 --- a/httpd/Dockerfile +++ b/httpd/Dockerfile @@ -18,6 +18,15 @@ RUN source /os-release && \ --bundles=httpd --no-scripts \ && rm -rf /install_root/var/lib/swupd/* +# For some Host OS configuration with redirect_dir on, +# extra data are saved on the upper layer when the same +# file exists on different layers. To minimize docker +# image size, remove the overlapped files before copy. +RUN mkdir /os_core_install +COPY --from=clearlinux/os-core:latest / /os_core_install/ +RUN cd / && \ + find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true + FROM clearlinux/os-core:latest MAINTAINER qi.zheng@intel.com diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 6bcdb77..8ab2cee 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -20,6 +20,15 @@ RUN source /os-release && \ --bundles=mariadb --no-scripts \ && rm -rf /install_root/var/lib/swupd/* +# For some Host OS configuration with redirect_dir on, +# extra data are saved on the upper layer when the same +# file exists on different layers. To minimize docker +# image size, remove the overlapped files before copy. +RUN mkdir /os_core_install +COPY --from=clearlinux/os-core:latest / /os_core_install/ +RUN cd / && \ + find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true + FROM clearlinux/os-core:latest MAINTAINER qi.zheng@intel.com diff --git a/memcached/Dockerfile b/memcached/Dockerfile index ac3dc56..0d30045 100644 --- a/memcached/Dockerfile +++ b/memcached/Dockerfile @@ -18,6 +18,15 @@ RUN source /os-release && \ --bundles=memcached --no-scripts \ && rm -rf /install_root/var/lib/swupd/* +# For some Host OS configuration with redirect_dir on, +# extra data are saved on the upper layer when the same +# file exists on different layers. To minimize docker +# image size, remove the overlapped files before copy. +RUN mkdir /os_core_install +COPY --from=clearlinux/os-core:latest / /os_core_install/ +RUN cd / && \ + find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true + FROM clearlinux/os-core:latest MAINTAINER qi.zheng@intel.com diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 0016eec..3d16111 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -18,6 +18,15 @@ RUN source /os-release && \ --bundles=nginx --no-scripts \ && rm -rf /install_root/var/lib/swupd/* +# For some Host OS configuration with redirect_dir on, +# extra data are saved on the upper layer when the same +# file exists on different layers. To minimize docker +# image size, remove the overlapped files before copy. +RUN mkdir /os_core_install +COPY --from=clearlinux/os-core:latest / /os_core_install/ +RUN cd / && \ + find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true + FROM clearlinux/os-core:latest MAINTAINER bin.yang@intel.com diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 7148207..c3ec0b4 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -19,6 +19,15 @@ RUN source /os-release && \ --path /install_root --statedir /swupd-state \ --bundles=postgresql --no-scripts +# For some Host OS configuration with redirect_dir on, +# extra data are saved on the upper layer when the same +# file exists on different layers. To minimize docker +# image size, remove the overlapped files before copy. +RUN mkdir /os_core_install +COPY --from=clearlinux/os-core:latest / /os_core_install/ +RUN cd / && \ + find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true + FROM clearlinux/os-core:latest COPY --from=builder /install_root /