From 5cc219cf7227ef1be4aa5a0cbf50369e3ce1b691 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 24 May 2017 15:14:42 +0100 Subject: [PATCH] swarmd: Modernize build Uses the alpine base container. Networking is not disabled because we still clone at build time. No swarmd.yml update because the commit referenced here no longer exists in the upstream repo after a force push. This will change in the next commit. Signed-off-by: Ian Campbell --- projects/swarmd/swarmd/Dockerfile | 22 ++++++++++++++++------ projects/swarmd/swarmd/Makefile | 5 +++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/projects/swarmd/swarmd/Dockerfile b/projects/swarmd/swarmd/Dockerfile index 94c6d6605..404ef382a 100644 --- a/projects/swarmd/swarmd/Dockerfile +++ b/projects/swarmd/swarmd/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.7-alpine3.5 AS build +FROM linuxkit/alpine:630ee558e4869672fae230c78364e367b8ea67a9 AS build RUN \ apk update && apk upgrade && \ @@ -6,10 +6,13 @@ RUN \ ca-certificates \ gcc \ git \ + go \ libc-dev \ make \ && true +ENV GOPATH=/root/go + # PR https://github.com/docker/swarmkit/pull/1965 from ijc25/containerd ENV SWARMKIT_PR=1965 ENV SWARMKIT_COMMIT=321b9c6600a9422c3245b277a1b3ae599244d4b7 @@ -23,14 +26,21 @@ RUN git checkout $SWARMKIT_COMMIT RUN make binaries GO_GCFLAGS="-buildmode pie --ldflags '-extldflags \"-fno-PIC -static\"'" -RUN mkdir -p /build/dist/usr/bin/ /build/dist/etc -RUN cp bin/swarmd bin/swarmctl /build/dist/usr/bin/ -RUN strip /build/dist/usr/bin/swarmd /build/dist/usr/bin/swarmctl +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk add --no-cache --initdb -p /out \ + alpine-baselayout \ + busybox \ + ca-certificates \ + iptables \ + musl \ + util-linux -RUN cp -r /etc/ssl /build/dist/etc/ssl +RUN mkdir -p /out/usr/bin/ /out/etc +RUN cp bin/swarmd bin/swarmctl /out/usr/bin/ +RUN strip /out/usr/bin/swarmd /out/usr/bin/swarmctl FROM scratch WORKDIR / ENTRYPOINT [] -COPY --from=build /build/dist / +COPY --from=build /out / CMD ["/usr/bin/swarmd", "--containerd-addr=/run/containerd/containerd.sock", "--log-level=debug", "--state-dir=/var/lib/swarmd"] diff --git a/projects/swarmd/swarmd/Makefile b/projects/swarmd/swarmd/Makefile index 5b4340b17..13ae4dd66 100644 --- a/projects/swarmd/swarmd/Makefile +++ b/projects/swarmd/swarmd/Makefile @@ -1,6 +1,7 @@ .PHONY: tag push all: push +ORG?=linuxkit IMAGE=swarmd HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') @@ -8,7 +9,7 @@ HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') default: push tag: Dockerfile - docker build -t linuxkit/$(IMAGE):$(HASH) . + docker build --no-cache -t $(ORG)/$(IMAGE):$(HASH) . push: tag - docker pull linuxkit/$(IMAGE):$(HASH) || docker push linuxkit/$(IMAGE):$(HASH) + docker pull $(ORG)/$(IMAGE):$(HASH) || docker push $(ORG)/$(IMAGE):$(HASH)