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

13
tools/tini/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
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`.