From 77c5bd021d526dc60ae651532135b0337c25070b Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 26 Jul 2017 11:58:19 +0100 Subject: [PATCH] test-kernel-config: Rework for multistage build and package.mk Network is required to fetch the check script. Signed-off-by: Ian Campbell --- test/pkg/kernel-config/Dockerfile | 14 ++++++++++---- test/pkg/kernel-config/Makefile | 30 +++--------------------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/test/pkg/kernel-config/Dockerfile b/test/pkg/kernel-config/Dockerfile index a0a47bb58..00b1aa559 100644 --- a/test/pkg/kernel-config/Dockerfile +++ b/test/pkg/kernel-config/Dockerfile @@ -1,6 +1,12 @@ -FROM alpine:3.5 -RUN apk update && apk upgrade && apk add --no-cache bash -ADD https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh /check-config.sh -ADD . ./ +FROM linuxkit/alpine:34af9cb1990debd17fae6d4198c62ce3910d9908 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 musl bash + +ADD https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh /out/check-config.sh +ADD . ./out + +FROM scratch +COPY --from=mirror /out / ENTRYPOINT ["/bin/sh", "/check.sh"] LABEL org.mobyproject.config='{"readonly": true, "binds": ["/lib/modules:/lib/modules", "/dev:/dev", "/sys:/sys"], "capabilities": ["all"]}' diff --git a/test/pkg/kernel-config/Makefile b/test/pkg/kernel-config/Makefile index 3ae702705..72f1ad11b 100644 --- a/test/pkg/kernel-config/Makefile +++ b/test/pkg/kernel-config/Makefile @@ -1,29 +1,5 @@ -.PHONY: tag push - -BASE=alpine:3.5 IMAGE=test-kernel-config +DEPS=$(wildcard *.sh) +NETWORK=1 -default: push - -hash: Dockerfile check.sh check-kernel-config.sh - DOCKER_CONTENT_TRUST=1 docker pull $(BASE) - tar cf - $^ | docker build --no-cache -t $(IMAGE):build - - docker run --rm --entrypoint=/bin/sh $(IMAGE):build -c "cat $^ /lib/apk/db/installed | sha1sum" | sed 's/ .*//' > hash - -push: hash - DOCKER_CONTENT_TRUST=1 docker pull linuxkit/$(IMAGE):$(shell cat hash) || \ - (docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \ - DOCKER_CONTENT_TRUST=1 docker push linuxkit/$(IMAGE):$(shell cat hash)) - docker rmi $(IMAGE):build - rm -f hash - -tag: hash - docker pull linuxkit/$(IMAGE):$(shell cat hash) || \ - docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) - docker rmi $(IMAGE):build - rm -f hash - -clean: - rm -f hash - -.DELETE_ON_ERROR: +include ../../../pkg/package.mk