mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
Modernise swarmd pkg build
Uses multi stage builds and the tree-sh as tag. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
parent
1b31a0ea3b
commit
a28d34f18c
@ -1,4 +1,4 @@
|
||||
FROM golang:1.7-alpine3.5
|
||||
FROM golang:1.7-alpine3.5 AS build
|
||||
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
@ -10,9 +10,6 @@ RUN \
|
||||
make \
|
||||
&& true
|
||||
|
||||
WORKDIR /
|
||||
COPY Dockerfile.build Dockerfile.pkg Makefile /build/
|
||||
|
||||
# PR https://github.com/docker/swarmkit/pull/1965 from ijc25/containerd
|
||||
ENV SWARMKIT_PR=1965
|
||||
ENV SWARMKIT_COMMIT=82e9f43d84e9a0586903392cbe5bbac15fdbf552
|
||||
@ -32,5 +29,8 @@ RUN strip /build/dist/usr/bin/swarmd /build/dist/usr/bin/swarmctl
|
||||
|
||||
RUN cp -r /etc/ssl /build/dist/etc/ssl
|
||||
|
||||
WORKDIR /build
|
||||
CMD ["/bin/tar", "cf", "-", "-C", "dist", "."]
|
||||
FROM scratch
|
||||
WORKDIR /
|
||||
ENTRYPOINT []
|
||||
COPY --from=build /build/dist /
|
||||
CMD ["/usr/bin/swarmd", "--containerd-addr=/run/containerd/containerd.sock", "--log-level=debug", "--state-dir=/var/lib/swarmd"]
|
@ -1,4 +0,0 @@
|
||||
FROM scratch
|
||||
WORKDIR /
|
||||
ADD swarmd.tar .
|
||||
CMD ["/usr/bin/swarmd", "--containerd-addr=/run/containerd/containerd.sock", "--log-level=debug", "--state-dir=/var/lib/swarmd"]
|
@ -1,38 +1,14 @@
|
||||
.PHONY: tag push clean container
|
||||
.PHONY: tag push
|
||||
all: push
|
||||
|
||||
SHASUM=alpine:3.5
|
||||
IMAGE=swarmd
|
||||
DEPS=Dockerfile.build Makefile
|
||||
|
||||
# Include Dockerfile.pkg here so hash works
|
||||
swarmd.tag: $(DEPS) Dockerfile.pkg
|
||||
BUILD=$$(tar cf - $^ | docker build -f $< -q -) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && echo "$$BUILD" > $@
|
||||
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
||||
|
||||
swarmd.tar: swarmd.tag
|
||||
docker run --rm --net=none --log-driver=none $(shell cat swarmd.tag) > $@
|
||||
default: push
|
||||
|
||||
container: Dockerfile.pkg swarmd.tar
|
||||
tar cf - $^ | docker build --no-cache -f $< -t $(IMAGE):build -
|
||||
tag: Dockerfile
|
||||
docker build -t linuxkit/$(IMAGE):$(HASH) .
|
||||
|
||||
hash: $(DEPS) Dockerfile.pkg
|
||||
find $^ -type f | xargs cat | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@
|
||||
|
||||
push: hash container
|
||||
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 container
|
||||
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
|
||||
rm -f swarmd.tag swarmd.tar
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
push: tag
|
||||
docker pull linuxkit/$(IMAGE):$(HASH) || docker push linuxkit/$(IMAGE):$(HASH)
|
||||
|
Loading…
Reference in New Issue
Block a user