mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
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:
parent
85bcee93dd
commit
60a12f1c52
@ -1,17 +0,0 @@
|
||||
FROM alpine:3.5
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
apk add \
|
||||
automake \
|
||||
bash \
|
||||
build-base \
|
||||
git \
|
||||
&& true
|
||||
COPY . .
|
||||
# 0.7.2
|
||||
ENV LDFLAGS=--static
|
||||
RUN git clone https://github.com/landley/toybox.git && \
|
||||
cd toybox && git checkout b27d5d9ad0c56014d8661d91f69ee498bbbe4cf9 && \
|
||||
make defconfig
|
||||
WORKDIR /toybox
|
||||
ENTRYPOINT ["/build.sh"]
|
@ -1,29 +0,0 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=alpine:3.5
|
||||
IMAGE=alpine-build-toybox
|
||||
|
||||
default: push
|
||||
|
||||
hash: Dockerfile build.sh
|
||||
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 /build.sh /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:
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
FILES=$@
|
||||
make $FILES > /dev/null
|
||||
[ $# -eq 0 ] && FILES=toybox
|
||||
# TODO symlinks if just use toybox
|
||||
mkdir -p /out/bin
|
||||
mv $FILES /out/bin
|
||||
printf "FROM scratch\nCOPY bin/ bin/\n" > /out/Dockerfile
|
||||
cd /out
|
||||
tar cf - .
|
@ -1,28 +0,0 @@
|
||||
.PHONY: tag push
|
||||
BASE=linuxkit/alpine-build-toybox:1855c262e3b2b252540bab17dc09f0bb292b0633@sha256:ef748ed99678ac0a72ccccb975c45bc1c7b706fe9047c3ac62b2b80025b33d3f
|
||||
IMAGE=toybox-media
|
||||
|
||||
default: push
|
||||
|
||||
hash:
|
||||
docker run --rm $(BASE) ls tar sh find sha1sum | \
|
||||
docker build -q -t $(IMAGE):build -
|
||||
docker run --rm $(IMAGE):build tar cf - bin | docker run -i $(IMAGE):build sha1sum -b - > 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:
|
18
tools/toybox-media/Dockerfile
Normal file
18
tools/toybox-media/Dockerfile
Normal 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/
|
26
tools/toybox-media/Makefile
Normal file
26
tools/toybox-media/Makefile
Normal 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:
|
3
tools/toybox-media/README.md
Normal file
3
tools/toybox-media/README.md
Normal 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).
|
Loading…
Reference in New Issue
Block a user