From 7420a00ba5b7644ccf941607825e179170db8100 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Wed, 17 Aug 2016 00:28:08 +0100 Subject: [PATCH] [WIP] Make builds repeatable by tagging an image based on hash of package install This tags a base Alpine image with the packages we use by finding the has of the package install manifest and using that to tag the image on hub. Hub org needs changing, and not sure how this will work out yet. Signed-off-by: Justin Cormack --- alpine/Dockerfile | 27 ++------------------------- alpine/base/.gitignore | 1 + alpine/base/Dockerfile | 26 ++++++++++++++++++++++++++ alpine/base/Makefile | 26 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 alpine/base/.gitignore create mode 100644 alpine/base/Dockerfile create mode 100644 alpine/base/Makefile diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 1bd036c4c..efdb23dca 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -1,34 +1,11 @@ -FROM alpine:3.4 +FROM justincormack/moby-alpine-base:0d79ff85d10a7d86067a3893e8a1f52ff3a073da ENV ARCH=x86_64 RUN \ addgroup -g 50 docker && \ adduser -G docker -u 1001 -s /bin/sh -D -g "Docker" docker && \ - passwd -d root && \ - apk update && apk upgrade && \ - apk add \ - e2fsprogs \ - chrony \ - git \ - xz \ - iptables \ - sfdisk \ - lvm2 \ - syslinux \ - openrc \ - busybox-initscripts \ - alpine-conf \ - bind-tools \ - openssh-client \ - strace \ - fuse \ - util-linux \ - cifs-utils \ - e2fsprogs-extra \ - openssl \ - jq \ - && rm -rf /var/cache/apk/* + passwd -d root COPY etc /etc/ RUN mkdir -p /etc/docker diff --git a/alpine/base/.gitignore b/alpine/base/.gitignore new file mode 100644 index 000000000..b79c9762f --- /dev/null +++ b/alpine/base/.gitignore @@ -0,0 +1 @@ +hash diff --git a/alpine/base/Dockerfile b/alpine/base/Dockerfile new file mode 100644 index 000000000..fabca5a40 --- /dev/null +++ b/alpine/base/Dockerfile @@ -0,0 +1,26 @@ +FROM alpine:3.4 + +RUN \ + apk update && apk upgrade && \ + apk add \ + e2fsprogs \ + chrony \ + git \ + xz \ + iptables \ + sfdisk \ + lvm2 \ + syslinux \ + openrc \ + busybox-initscripts \ + alpine-conf \ + bind-tools \ + openssh-client \ + strace \ + fuse \ + util-linux \ + cifs-utils \ + e2fsprogs-extra \ + openssl \ + jq \ + && rm -rf /var/cache/apk/* diff --git a/alpine/base/Makefile b/alpine/base/Makefile new file mode 100644 index 000000000..90c4ea606 --- /dev/null +++ b/alpine/base/Makefile @@ -0,0 +1,26 @@ +.PHONY: tag push + +default: push + +hash: + docker pull alpine:3.4 + tar cf - Dockerfile | docker build --no-cache -t justincormack/moby-alpine-base:build - + rm -f hash + docker run justincormack/moby-alpine-base:build sha1sum /lib/apk/db/installed | sed 's/ .*//' > hash + +push: hash + docker pull justincormack/moby-alpine-base:$(shell cat hash) || \ + (docker tag justincormack/moby-alpine-base:build justincormack/moby-alpine-base:latest && \ + docker tag justincormack/moby-alpine-base:build justincormack/moby-alpine-base:$(shell cat hash) && \ + docker push justincormack/moby-alpine-base:$(shell cat hash) && \ + docker push justincormack/moby-alpine-base:latest) + rm -f hash + +tag: hash + docker pull justincormack/moby-alpine-base:$(shell cat hash) || \ + (docker tag justincormack/moby-alpine-base:build justincormack/moby-alpine-base:latest && \ + docker tag justincormack/moby-alpine-base:build justincormack/moby-alpine-base:$(shell cat hash)) + rm -f hash + +clean: + rm -f hash