From ee7d785b84e0ae54ae9ec1e4cba8a3e6182233aa Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 18 Jul 2017 12:24:46 +0100 Subject: [PATCH] kubernetes: minimise size of image cache images The total size of the images in the common and control-plane cache is 251M and 528M respectively. This changes drops the size of the cache images from 353M to 274M and from 630M to 530M, reducing the overhead from ~100M to ~20M. The initrd images shrink from 273M to 246M and from 416M to 363M (the initrd's are compressed). Signed-off-by: Ian Campbell --- projects/kubernetes/image-cache/Dockerfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/projects/kubernetes/image-cache/Dockerfile b/projects/kubernetes/image-cache/Dockerfile index 33815b306..a333ede8e 100644 --- a/projects/kubernetes/image-cache/Dockerfile +++ b/projects/kubernetes/image-cache/Dockerfile @@ -1,4 +1,21 @@ -FROM docker:17.06.0-ce-dind +FROM docker:17.06.0-ce-dind AS docker + +# Nothing to do in here, just for COPY --from=docker below + +FROM linuxkit/alpine:9bcf61f605ef0ce36cc94d59b8eac307862de6e1 AS build + +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + busybox + +# Remove apk residuals. We have a read-only rootfs, so apk is of no use. +RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache + +FROM scratch +WORKDIR / +COPY --from=build /out / +COPY --from=docker /usr/local/bin/docker /usr/local/bin/docker COPY *.tar /images/ ENTRYPOINT [ "/bin/sh", "-c" ] CMD [ "for image in /images/*.tar ; do docker image load -i $image && rm -f $image ; done" ]