From 9f6578783beccd39593f3bb6ecd4a8c316f1206e Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Thu, 18 May 2017 15:27:39 +0100 Subject: [PATCH] pkg: Roll the swap package from linuxkit/alpine Also convert to a multi-stage build and make the make the HUB org/registry build time configurable. Signed-off-by: Rolf Neugebauer --- pkg/swap/Dockerfile | 28 ++++++++++++++++------------ pkg/swap/Makefile | 35 ++++++++++------------------------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/pkg/swap/Dockerfile b/pkg/swap/Dockerfile index 9a6d9e002..955415aa1 100644 --- a/pkg/swap/Dockerfile +++ b/pkg/swap/Dockerfile @@ -1,13 +1,17 @@ -FROM alpine:3.5 +FROM linuxkit/alpine:6336329f15b4166514782eaa555cf0ffd35c519c@sha256:f6c2ce92910b1d6e4e5557850a554f4a3ae9f66c1e89ad86a24d6c6e550f165e 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 \ + cryptsetup \ + musl \ + util-linux +RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache -# swap command - only minimal Alpine install - -# use util-linux to get swapfile utils, cryptsetup -# at some point, hopefully use our own mkswap and swapon, as well as cryptsetup -RUN apk add --update util-linux cryptsetup - -# add the entrypoint and make it executable -COPY . ./ - -# ENTRYPOINT -ENTRYPOINT swap.sh +FROM scratch +ENTRYPOINT [] +CMD [] +WORKDIR / +COPY --from=mirror /out/ / +COPY /swap.sh . +ENTRYPOINT ["swap.sh"] diff --git a/pkg/swap/Makefile b/pkg/swap/Makefile index 06e89bdcd..1e9783a81 100644 --- a/pkg/swap/Makefile +++ b/pkg/swap/Makefile @@ -1,30 +1,15 @@ -# copy from mount -.PHONY: tag push clean - -BASE=alpine:3.5 -IMAGE=linuxkit/swap - +.PHONY: tag push default: push -hash: Dockerfile swap.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/ .*//' > $@ +ORG?=linuxkit +IMAGE=swap +DEPS=Dockerfile swap.sh -push: hash - docker pull $(IMAGE):$(shell cat hash) || \ - (docker tag $(IMAGE):build $(IMAGE):$(shell cat hash) && \ - docker push $(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 $(IMAGE):$(shell cat hash) || \ - docker tag $(IMAGE):build $(IMAGE):$(shell cat hash) - docker rmi $(IMAGE):build - rm -f hash +tag: $(DEPS) + docker build --squash --no-cache --network=none -t $(ORG)/$(IMAGE):$(HASH) . -clean: - rm -f hash - -.DELETE_ON_ERROR: +push: tag + docker pull $(ORG)/$(IMAGE):$(HASH) || \ + docker push $(ORG)/$(IMAGE):$(HASH)