From 4ca0458526e340d136bc185e12ededabdf055979 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 21:31:38 +0100 Subject: [PATCH 1/7] tools: Use a multi-stage build for mkimage-iso-bios mkimage-iso-bios contained the full alpine base. Only copy packages actually needed. Signed-off-by: Rolf Neugebauer --- tools/mkimage-iso-bios/Dockerfile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/mkimage-iso-bios/Dockerfile b/tools/mkimage-iso-bios/Dockerfile index 12b0fef6e..be78af6a6 100644 --- a/tools/mkimage-iso-bios/Dockerfile +++ b/tools/mkimage-iso-bios/Dockerfile @@ -1,13 +1,16 @@ -FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc - -RUN \ - apk update && apk upgrade && \ - apk add --no-cache \ - libarchive-tools \ - cdrkit \ - syslinux \ - && true +FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc as mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + busybox \ + cdrkit \ + libarchive-tools \ + syslinux \ + && true +RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories +FROM scratch +WORKDIR / +COPY --from=mirror /out/ / COPY . . - ENTRYPOINT [ "/make-iso" ] From 47bff24b94e98f90fa07d42b309decbdaf1b84b2 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 21:35:21 +0100 Subject: [PATCH 2/7] tools: Fix mkimage-iso-efi Build the final image from SCRATCH instead of the alpine base. Should be a lot smaller now. Signed-off-by: Rolf Neugebauer --- tools/mkimage-iso-efi/Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/mkimage-iso-efi/Dockerfile b/tools/mkimage-iso-efi/Dockerfile index ab586709c..7c55144a0 100644 --- a/tools/mkimage-iso-efi/Dockerfile +++ b/tools/mkimage-iso-efi/Dockerfile @@ -1,5 +1,4 @@ FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS grub-build - RUN apk add \ automake \ make \ @@ -39,19 +38,22 @@ RUN mkdir /grub-lib && \ ;; \ esac -FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS make-img - -RUN \ - apk update && apk upgrade && \ - apk add --no-cache \ +FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + binutils \ + busybox \ dosfstools \ libarchive-tools \ - binutils \ mtools \ xorriso \ && true +RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories -COPY . . +FROM scratch +WORKDIR / +COPY --from=mirror /out/ / COPY --from=grub-build /grub-lib/BOOT*.EFI /usr/local/share/ - +COPY . . ENTRYPOINT [ "/make-efi" ] From 99e65ef998e370097b8016d61b87d3740e295232 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 21:38:11 +0100 Subject: [PATCH 3/7] tools: Fix mkimage-qcow2-efi Build the final image from scratch instead of the full alpine base. Signed-off-by: Rolf Neugebauer --- tools/mkimage-qcow2-efi/Dockerfile | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tools/mkimage-qcow2-efi/Dockerfile b/tools/mkimage-qcow2-efi/Dockerfile index 61e009120..e1acb0e8a 100644 --- a/tools/mkimage-qcow2-efi/Dockerfile +++ b/tools/mkimage-qcow2-efi/Dockerfile @@ -1,19 +1,17 @@ FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS grub-build - RUN apk add \ + autoconf \ automake \ - make \ bison \ - gettext \ - flex \ gcc \ + gettext \ git \ - libtool \ + flex \ libc-dev \ + libtool \ linux-headers \ - python3 \ - - autoconf + make \ + python3 # because python is not available RUN ln -s python3 /usr/bin/python @@ -40,22 +38,25 @@ RUN mkdir /grub-lib && \ ;; \ esac -FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS make-img - -RUN \ - apk update && apk upgrade && \ - apk add --no-cache \ +FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + binutils \ + busybox \ dosfstools \ libarchive-tools \ - binutils \ mtools \ + qemu-img \ sfdisk \ sgdisk \ xfsprogs \ - qemu-img \ && true +RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories -COPY . . +FROM scratch +WORKDIR / +COPY --from=mirror /out/ / COPY --from=grub-build /grub-lib/BOOT*.EFI /usr/local/share/ - +COPY . . ENTRYPOINT [ "/make-efi" ] From 24d8ecc9431a0f611097b4100e92613dec670e6f Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 21:40:27 +0100 Subject: [PATCH 4/7] tools: Fix mkimage-raw-bios Build the final image from scratch instead of the full alpine base image. Signed-off-by: Rolf Neugebauer --- tools/mkimage-raw-bios/Dockerfile | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/mkimage-raw-bios/Dockerfile b/tools/mkimage-raw-bios/Dockerfile index 08eb6e6bd..6d8405760 100644 --- a/tools/mkimage-raw-bios/Dockerfile +++ b/tools/mkimage-raw-bios/Dockerfile @@ -1,14 +1,17 @@ -FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc - -RUN \ - apk update && apk upgrade && \ - apk add --no-cache \ - dosfstools \ - libarchive-tools \ - sfdisk \ - syslinux \ - && true +FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + busybox \ + dosfstools \ + libarchive-tools \ + sfdisk \ + syslinux \ + && true +RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories +FROM scratch +WORKDIR / +COPY --from=mirror /out/ / COPY . . - ENTRYPOINT [ "/make-bios" ] From fe569b627ab5b4855dd246e8fbe1ee52677d95d2 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 21:43:59 +0100 Subject: [PATCH 5/7] tools: Fix mkimage-raw-efi Use a scratch image as the base instead of the full alpine base. Signed-off-by: Rolf Neugebauer --- tools/mkimage-raw-efi/Dockerfile | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/mkimage-raw-efi/Dockerfile b/tools/mkimage-raw-efi/Dockerfile index 4a01e027d..ece392995 100644 --- a/tools/mkimage-raw-efi/Dockerfile +++ b/tools/mkimage-raw-efi/Dockerfile @@ -1,20 +1,17 @@ FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS grub-build - RUN apk add \ + autoconf \ automake \ - make \ bison \ - gettext \ - flex \ gcc \ + gettext \ git \ - libtool \ + flex \ libc-dev \ + libtool \ linux-headers \ - python3 \ - - autoconf - + make \ + python3 # because python is not available RUN ln -s python3 /usr/bin/python @@ -40,21 +37,24 @@ RUN mkdir /grub-lib && \ ;; \ esac -FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS make-img - -RUN \ - apk update && apk upgrade && \ - apk add --no-cache \ +FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + binutils \ + busybox \ dosfstools \ libarchive-tools \ - binutils \ mtools \ sfdisk \ sgdisk \ xfsprogs \ && true +RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories -COPY . . +FROM scratch +WORKDIR / +COPY --from=mirror /out/ / COPY --from=grub-build /grub-lib/BOOT*.EFI /usr/local/share/ - +COPY . . ENTRYPOINT [ "/make-efi" ] From a9552aee2ddd579b60d66e105578a1d187c5ea6a Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 21:48:40 +0100 Subject: [PATCH 6/7] tools: Fix mkimage-squashfs Us a scratch image as the base instead of the alpine base image. Signed-off-by: Rolf Neugebauer --- tools/mkimage-squashfs/Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/mkimage-squashfs/Dockerfile b/tools/mkimage-squashfs/Dockerfile index 3b8285ff4..74161ebbb 100644 --- a/tools/mkimage-squashfs/Dockerfile +++ b/tools/mkimage-squashfs/Dockerfile @@ -1,12 +1,15 @@ -FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc - -RUN \ - apk update && apk upgrade && \ - apk add --no-cache \ +FROM linuxkit/alpine:daed76b8f1d28cdeeee215a95b9671c682a405dc AS mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + busybox \ libarchive-tools \ squashfs-tools \ && true +RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories +FROM scratch +WORKDIR / +COPY --from=mirror /out/ / COPY . . - ENTRYPOINT [ "/make-squashfs" ] From 66b74178197db04b2997d6f616175668773fa401 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 24 Jul 2018 22:29:46 +0100 Subject: [PATCH 7/7] cmd: Update mkimage-* hashes Signed-off-by: Rolf Neugebauer --- src/cmd/linuxkit/moby/output.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/linuxkit/moby/output.go b/src/cmd/linuxkit/moby/output.go index f64a85ced..ec81527b1 100644 --- a/src/cmd/linuxkit/moby/output.go +++ b/src/cmd/linuxkit/moby/output.go @@ -16,13 +16,13 @@ import ( var ( outputImages = map[string]string{ - "iso-bios": "linuxkit/mkimage-iso-bios:fd0092700bc19ea36cc8dccccc9799b7847b4909", - "iso-efi": "linuxkit/mkimage-iso-efi:79148c60bbf2a9526d976d708840492d85b0c576", - "raw-bios": "linuxkit/mkimage-raw-bios:0ff04de5d11a88b0712cdc85b2ee5f0b966ffccf", - "raw-efi": "linuxkit/mkimage-raw-efi:084f159cb44dc6c22351a70f1c1a043857be4e12", - "squashfs": "linuxkit/mkimage-squashfs:36f3fa106cfb7f8b818a828d7aebb27f946c9526", + "iso-bios": "linuxkit/mkimage-iso-bios:65254243f003cf0ac74c64b0a23b543195ddad8a", + "iso-efi": "linuxkit/mkimage-iso-efi:1f5556e56da8e82d52458667ad354b719f314eb2", + "raw-bios": "linuxkit/mkimage-raw-bios:2795f6282bdb8582934d5a0c2f1f859d3073336c", + "raw-efi": "linuxkit/mkimage-raw-efi:21fbe24aa2a9c6b2d5847da5b7337f727e31339c", + "squashfs": "linuxkit/mkimage-squashfs:9e3c0c2788665a54b949e79ebaacf66297ebd4df", "gcp": "linuxkit/mkimage-gcp:e6cdcf859ab06134c0c37a64ed5f886ec8dae1a1", - "qcow2-efi": "linuxkit/mkimage-qcow2-efi:0eb853459785fad0b518d8edad3b7434add6ad96", + "qcow2-efi": "linuxkit/mkimage-qcow2-efi:6a886a3f82d6d166f4ae540203cb3dffbc4cc12d", "vhd": "linuxkit/mkimage-vhd:3820219e5c350fe8ab2ec6a217272ae82f4b9242", "dynamic-vhd": "linuxkit/mkimage-dynamic-vhd:743ac9959fe6d3912ebd78b4fd490b117c53f1a6", "vmdk": "linuxkit/mkimage-vmdk:cee81a3ed9c44ae446ef7ebff8c42c1e77b3e1b5",