tools: Move toybox to ./tools and use a multi-stage build

Also use c-compile to compile it

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer
2017-04-23 14:55:51 +01:00
parent 85bcee93dd
commit 60a12f1c52
7 changed files with 47 additions and 85 deletions

View File

@@ -0,0 +1,18 @@
FROM linuxkit/c-compile:f52f485825c890d581e82a62af6906c1d33d8e5d@sha256:473fd283a090d3546e93915adacf00c69a23ff615c95c968c4a40e8723985853 AS toybox-build
COPY . .
ENV FILES="ls tar sh find sha1sum"
# 0.7.2
ENV LDFLAGS=--static
RUN git clone https://github.com/landley/toybox.git && \
cd toybox && git checkout b27d5d9ad0c56014d8661d91f69ee498bbbe4cf9 && \
make defconfig
WORKDIR /toybox
RUN make ${FILES}
RUN mkdir -p /out/bin
RUN cp ${FILES} /out/bin
FROM scratch
ENTRYPOINT []
CMD []
WORKDIR /
COPY --from=toybox-build out/bin bin/

View File

@@ -0,0 +1,26 @@
.PHONY: tag push
default: push
IMAGE=toybox-media
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:

View File

@@ -0,0 +1,3 @@
`linuxkit/toybox-media` is a small container image, which can be use
to distribute other files in. It contains a basic shell, `tar`, `ls`,
`find`, and `sha1sum`. It's compiled from [toybox](https://github.com/landley/toybox.git).