tools: Move tini to ./tools and convert to multi-stage build

Previously the "tini" contained the entire build. Using the
multi-stage build creates a new "tini" base image, which only
contains the "/bin/tini". This image can be used as the base
image for packages requiring "tini".

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-04-23 10:12:24 +01:00
parent 370f8e7eb0
commit 85bcee93dd
8 changed files with 48 additions and 64 deletions

View File

@ -1,29 +0,0 @@
.PHONY: tag push
BASE=alpine:3.5
IMAGE=tini
default: push
hash: Dockerfile
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --rm --entrypoint sh $(IMAGE):build -c 'cat /Dockerfile /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > hash
push: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
docker push linuxkit/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@ -1,11 +0,0 @@
FROM linuxkit/go-compile:4513068d9a7e919e4ec42e2d7ee879ff5b95b7f5@sha256:bdfadbe3e4ec699ca45b67453662321ec270f2d1a1dbdbf09625776d3ebd68c5
ENV VIRTSOCK_COMMIT=6b4dec728264e07c41e108caebd6bc2b72559a5f
RUN mkdir -p $GOPATH/src/github.com/rneugeba && \
cd $GOPATH/src/github.com/rneugeba && \
git clone https://github.com/rneugeba/virtsock.git
WORKDIR $GOPATH/src/github.com/rneugeba/virtsock
RUN git checkout $VIRTSOCK_COMMIT
RUN make build/virtsock_stress.linux
ENTRYPOINT ["cat", "build/virtsock_stress.linux"]

View File

@ -1,3 +0,0 @@
FROM scratch
COPY . ./
CMD ["/bin/tini", "/bin/virtsock_stress", "-s", "-v", "1"]

View File

@ -1,16 +1,13 @@
FROM alpine:3.5
RUN \
apk update && apk upgrade && \
apk add \
cmake \
gcc \
make \
musl-dev \
vim \
&& true
FROM linuxkit/c-compile:f52f485825c890d581e82a62af6906c1d33d8e5d@sha256:473fd283a090d3546e93915adacf00c69a23ff615c95c968c4a40e8723985853 AS tini-build
COPY . /
ENV TINI_VERSION=0.13.0
ADD https://github.com/krallin/tini/archive/v${TINI_VERSION}.tar.gz tini-${TINI_VERSION}.tar.gz
RUN zcat tini-${TINI_VERSION}.tar.gz | tar xvf -
RUN cd tini-${TINI_VERSION} && cmake . && make && cp -a tini-static /bin/tini
FROM scratch
ENTRYPOINT []
CMD []
WORKDIR /
COPY --from=tini-build bin/tini bin/tini

26
tools/tini/Makefile Normal file
View File

@ -0,0 +1,26 @@
.PHONY: tag push
default: push
IMAGE=tini
SHA_IMAGE=alpine:3.5@sha256:dfbd4a3a8ebca874ebd2474f044a0b33600d4523d03b0df76e5c5986cb02d7e8
DEPS=Dockerfile Makefile
hash: $(DEPS)
find $^ -type f | xargs cat | docker run --rm -i $(SHA_IMAGE) sha1sum - | sed 's/ .*//' > hash
tag: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
(docker build --no-cache -t $(IMAGE):build . && \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash))
push: tag
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker push linuxkit/$(IMAGE):$(shell cat hash)
rm -f hash
docker rmi $(IMAGE):build || true
clean:
rm -f hash
docker rmi $(IMAGE):build || true
.DELETE_ON_ERROR:

4
tools/tini/README.md Normal file
View File

@ -0,0 +1,4 @@
[tini](https://github.com/krallin/tini) is a tiny program which can be
used as a minimal `init` process for container images.
The `linuxkit/tini` image just contains `/bin/tini` and can be used as the base image by packages, requiring `tini`.