From 3ffa912c41e72472f23db35149bf64419fb1af55 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Sun, 9 Apr 2017 12:53:46 +0100 Subject: [PATCH] Move mount back to its own package, not inside docker Signed-off-by: Justin Cormack --- pkg/docker-ce/Dockerfile | 4 +-- pkg/docker-ce/Makefile | 2 +- pkg/mount/Dockerfile | 11 ++++++++ pkg/mount/Makefile | 29 +++++++++++++++++++++ pkg/{docker-ce/docker.sh => mount/mount.sh} | 15 +++++------ 5 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 pkg/mount/Dockerfile create mode 100644 pkg/mount/Makefile rename pkg/{docker-ce/docker.sh => mount/mount.sh} (80%) diff --git a/pkg/docker-ce/Dockerfile b/pkg/docker-ce/Dockerfile index 45a44e176..2fb298809 100644 --- a/pkg/docker-ce/Dockerfile +++ b/pkg/docker-ce/Dockerfile @@ -38,7 +38,5 @@ RUN set -x \ && rm docker.tgz \ && docker -v -COPY . ./ - # use the Docker copy of tini as our init for zombie reaping -ENTRYPOINT ["/usr/bin/docker-init", "/bin/sh", "/docker.sh"] +ENTRYPOINT ["/usr/bin/docker-init", "/usr/bin/dockerd"] diff --git a/pkg/docker-ce/Makefile b/pkg/docker-ce/Makefile index 1cca96610..d3fcb0869 100644 --- a/pkg/docker-ce/Makefile +++ b/pkg/docker-ce/Makefile @@ -5,7 +5,7 @@ IMAGE=docker-ce default: push -hash: Dockerfile docker.sh +hash: Dockerfile DOCKER_CONTENT_TRUST=1 docker pull $(BASE) tar cf - $^ | docker build --no-cache -t $(IMAGE):build - docker run --entrypoint /bin/sh --rm $(IMAGE):build -c 'cat $^ /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > $@ diff --git a/pkg/mount/Dockerfile b/pkg/mount/Dockerfile new file mode 100644 index 000000000..8b5098209 --- /dev/null +++ b/pkg/mount/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.5 + +RUN \ + apk update && apk upgrade -a && \ + apk add --no-cache \ + jq \ + sfdisk \ + && true + +COPY . ./ +CMD ["/bin/sh", "/mount.sh"] diff --git a/pkg/mount/Makefile b/pkg/mount/Makefile new file mode 100644 index 000000000..13d9efd9f --- /dev/null +++ b/pkg/mount/Makefile @@ -0,0 +1,29 @@ +.PHONY: tag push + +BASE=alpine:3.5 +IMAGE=mount + +default: push + +hash: Dockerfile mount.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/ .*//' > $@ + +push: hash + docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ + (docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \ + docker push mobylinux/$(IMAGE):$(shell cat hash)) + docker rmi $(IMAGE):build + rm -f hash + +tag: hash + docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ + docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) + docker rmi $(IMAGE):build + rm -f hash + +clean: + rm -f hash + +.DELETE_ON_ERROR: diff --git a/pkg/docker-ce/docker.sh b/pkg/mount/mount.sh similarity index 80% rename from pkg/docker-ce/docker.sh rename to pkg/mount/mount.sh index 5ab37b090..724d594a9 100755 --- a/pkg/docker-ce/docker.sh +++ b/pkg/mount/mount.sh @@ -2,12 +2,14 @@ set -x +MOUNTPOINT="$1" + +[ -z "$MOUNTPOINT" ] && echo "No mountpoint specified" && exit 1 + +mkdir -p "$MOUNTPOINT" + mount_drive() { - MOUNTPOINT=/var/lib/docker - - mkdir -p "$MOUNTPOINT" - # TODO fix for multiple disks, cdroms etc DEVS="$(find /dev -maxdepth 1 -type b ! -name 'loop*' ! -name 'nbd*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | sort)" @@ -28,11 +30,6 @@ mount_drive() done echo "WARNING: Failed to mount a persistent volume (is there one?)" - - # not sure if we want to fatally bail here, in some debug situations it is ok - # exit 1 } mount_drive - -exec /usr/bin/dockerd