From 17adcefe6cbec1e8c5e195498590edc080fdbfe9 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Thu, 4 May 2017 14:56:50 +0100 Subject: [PATCH] pkg: Convert openntpd to use the Alpine base image and git tree hash Signed-off-by: Rolf Neugebauer --- pkg/openntpd/Dockerfile | 14 ++++++++------ pkg/openntpd/Makefile | 31 ++++++++----------------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/pkg/openntpd/Dockerfile b/pkg/openntpd/Dockerfile index 53eeeaf65..350d7948e 100644 --- a/pkg/openntpd/Dockerfile +++ b/pkg/openntpd/Dockerfile @@ -1,10 +1,12 @@ -FROM alpine:3.5 +FROM linuxkit/alpine:f0169b60fb260d74025496ae6fd93213fecaba8f@sha256:23743c7206ebe8a609442c5ac7084a26ed45ce8f5213960428bca264225849f1 AS mirror -RUN \ - apk update && apk upgrade -a && \ - apk add --no-cache \ - openntpd \ - && true +FROM alpine:3.5@sha256:dfbd4a3a8ebca874ebd2474f044a0b33600d4523d03b0df76e5c5986cb02d7e8 +COPY --from=mirror /etc/apk/repositories /etc/apk/repositories +COPY --from=mirror /etc/apk/keys /etc/apk/keys/ +COPY --from=mirror /mirror /mirror/ + +RUN apk add --no-cache openntpd && true +RUN rm -rf /mirror /etc/apk/repositories /etc/apk/keys COPY . . diff --git a/pkg/openntpd/Makefile b/pkg/openntpd/Makefile index c8567f47f..83ef89f60 100644 --- a/pkg/openntpd/Makefile +++ b/pkg/openntpd/Makefile @@ -1,29 +1,14 @@ -.PHONY: tag push clean container +.PHONY: tag push default: push IMAGE=openntpd +DEPS=Dockerfile etc/ntpd.conf -BASE=alpine:3.5 +HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') -hash: Dockerfile etc/ntpd.conf - DOCKER_CONTENT_TRUST=1 docker pull $(BASE) - tar cf - $^ | docker build --no-cache -t $(IMAGE):build - - docker run --rm $(IMAGE):build sh -c 'cat $^ /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > hash +tag: $(DEPS) + docker build --squash --no-cache --network=none -t linuxkit/$(IMAGE):$(HASH) . -push: hash - docker pull linuxkit/$(IMAGE):$(shell cat hash) || \ - (docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \ - 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 -rf hash - -.DELETE_ON_ERROR: +push: tag + docker pull linuxkit/$(IMAGE):$(HASH) || \ + docker push linuxkit/$(IMAGE):$(HASH)