From 95b13501f20e79b277ecb8d679fbaec739bc0136 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 30 May 2017 11:46:53 +0100 Subject: [PATCH] tests: Use the Alpine base image for the poweroff package Also convert it to use the git tree hash Signed-off-by: Rolf Neugebauer --- test/pkg/poweroff/Dockerfile | 12 ++++++++++-- test/pkg/poweroff/Makefile | 32 +++++++++----------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/test/pkg/poweroff/Dockerfile b/test/pkg/poweroff/Dockerfile index 597989a64..2c0e005ac 100644 --- a/test/pkg/poweroff/Dockerfile +++ b/test/pkg/poweroff/Dockerfile @@ -1,4 +1,12 @@ -FROM alpine:3.5 -ADD . ./ +FROM linuxkit/alpine:451603daf499e3a40308dbf5571dcffed2343ffa 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 +RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache + +FROM scratch +CMD [] +WORKDIR / +COPY --from=mirror /out/ / +COPY /poweroff.sh /poweroff.sh ENTRYPOINT ["/bin/sh", "/poweroff.sh"] LABEL org.mobyproject.config='{"pid": "host", "readonly": true, "capabilities": ["CAP_SYS_BOOT"]}' diff --git a/test/pkg/poweroff/Makefile b/test/pkg/poweroff/Makefile index b6637911b..05e38c2ab 100644 --- a/test/pkg/poweroff/Makefile +++ b/test/pkg/poweroff/Makefile @@ -1,29 +1,15 @@ .PHONY: tag push - -BASE=alpine:3.5 -IMAGE=poweroff - default: push -hash: Dockerfile poweroff.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 +ORG?=linuxkit +IMAGE=poweroff +DEPS=Dockerfile Makefile poweroff.sh -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 +HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') -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 +tag: $(DEPS) + docker build --no-cache --network=none -t $(ORG)/$(IMAGE):$(HASH) . -clean: - rm -f hash - -.DELETE_ON_ERROR: +push: tag + DOCKER_CONTENT_TRUST=1 docker pull $(ORG)/$(IMAGE):$(HASH) || \ + DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE):$(HASH)