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 <ian.campbell@docker.com>
This commit is contained in:
Ian Campbell 2017-05-24 15:14:42 +01:00
parent 6d495fc92f
commit 5cc219cf72
2 changed files with 19 additions and 8 deletions

View File

@ -1,4 +1,4 @@
FROM golang:1.7-alpine3.5 AS build FROM linuxkit/alpine:630ee558e4869672fae230c78364e367b8ea67a9 AS build
RUN \ RUN \
apk update && apk upgrade && \ apk update && apk upgrade && \
@ -6,10 +6,13 @@ RUN \
ca-certificates \ ca-certificates \
gcc \ gcc \
git \ git \
go \
libc-dev \ libc-dev \
make \ make \
&& true && true
ENV GOPATH=/root/go
# PR https://github.com/docker/swarmkit/pull/1965 from ijc25/containerd # PR https://github.com/docker/swarmkit/pull/1965 from ijc25/containerd
ENV SWARMKIT_PR=1965 ENV SWARMKIT_PR=1965
ENV SWARMKIT_COMMIT=321b9c6600a9422c3245b277a1b3ae599244d4b7 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 make binaries GO_GCFLAGS="-buildmode pie --ldflags '-extldflags \"-fno-PIC -static\"'"
RUN mkdir -p /build/dist/usr/bin/ /build/dist/etc RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN cp bin/swarmd bin/swarmctl /build/dist/usr/bin/ RUN apk add --no-cache --initdb -p /out \
RUN strip /build/dist/usr/bin/swarmd /build/dist/usr/bin/swarmctl 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 FROM scratch
WORKDIR / WORKDIR /
ENTRYPOINT [] 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"] CMD ["/usr/bin/swarmd", "--containerd-addr=/run/containerd/containerd.sock", "--log-level=debug", "--state-dir=/var/lib/swarmd"]

View File

@ -1,6 +1,7 @@
.PHONY: tag push .PHONY: tag push
all: push all: push
ORG?=linuxkit
IMAGE=swarmd IMAGE=swarmd
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') 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 default: push
tag: Dockerfile tag: Dockerfile
docker build -t linuxkit/$(IMAGE):$(HASH) . docker build --no-cache -t $(ORG)/$(IMAGE):$(HASH) .
push: tag push: tag
docker pull linuxkit/$(IMAGE):$(HASH) || docker push linuxkit/$(IMAGE):$(HASH) docker pull $(ORG)/$(IMAGE):$(HASH) || docker push $(ORG)/$(IMAGE):$(HASH)