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 \
|
RUN \
|
||||||
apk update && apk upgrade && \
|
apk update && apk upgrade && \
|
||||||
@ -10,9 +10,6 @@ RUN \
|
|||||||
make \
|
make \
|
||||||
&& true
|
&& true
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
COPY Dockerfile.build Dockerfile.pkg Makefile /build/
|
|
||||||
|
|
||||||
# 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=82e9f43d84e9a0586903392cbe5bbac15fdbf552
|
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
|
RUN cp -r /etc/ssl /build/dist/etc/ssl
|
||||||
|
|
||||||
WORKDIR /build
|
FROM scratch
|
||||||
CMD ["/bin/tar", "cf", "-", "-C", "dist", "."]
|
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
|
all: push
|
||||||
|
|
||||||
SHASUM=alpine:3.5
|
|
||||||
IMAGE=swarmd
|
IMAGE=swarmd
|
||||||
DEPS=Dockerfile.build Makefile
|
|
||||||
|
|
||||||
# Include Dockerfile.pkg here so hash works
|
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
||||||
swarmd.tag: $(DEPS) Dockerfile.pkg
|
|
||||||
BUILD=$$(tar cf - $^ | docker build -f $< -q -) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && echo "$$BUILD" > $@
|
|
||||||
|
|
||||||
swarmd.tar: swarmd.tag
|
default: push
|
||||||
docker run --rm --net=none --log-driver=none $(shell cat swarmd.tag) > $@
|
|
||||||
|
|
||||||
container: Dockerfile.pkg swarmd.tar
|
tag: Dockerfile
|
||||||
tar cf - $^ | docker build --no-cache -f $< -t $(IMAGE):build -
|
docker build -t linuxkit/$(IMAGE):$(HASH) .
|
||||||
|
|
||||||
hash: $(DEPS) Dockerfile.pkg
|
push: tag
|
||||||
find $^ -type f | xargs cat | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@
|
docker pull linuxkit/$(IMAGE):$(HASH) || docker push linuxkit/$(IMAGE):$(HASH)
|
||||||
|
|
||||||
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:
|
|
||||||
|
Loading…
Reference in New Issue
Block a user