mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-25 19:54:38 +00:00
test: Convert virtsock to use multi-stage build
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
8d1eb49fa7
commit
91dcb402c7
14
test/virtsock/Dockerfile
Normal file
14
test/virtsock/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM linuxkit/go-compile:4513068d9a7e919e4ec42e2d7ee879ff5b95b7f5@sha256:bdfadbe3e4ec699ca45b67453662321ec270f2d1a1dbdbf09625776d3ebd68c5 AS virtsock-build
|
||||||
|
|
||||||
|
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
|
||||||
|
RUN cp -a build/virtsock_stress.linux /virtsock_stress
|
||||||
|
|
||||||
|
FROM linuxkit/tini:6714d66b82b5397f497b2aa05764096ed1ffe7d7@sha256:ba594b96af6195737ce2df702196d7adea2cafde554e18940ee14ad575d27f3b
|
||||||
|
COPY --from=virtsock-build virtsock_stress bin/virtsock_stress
|
||||||
|
CMD ["/bin/tini", "/bin/virtsock_stress", "-s", "-v", "1"]
|
@ -1,46 +1,26 @@
|
|||||||
.PHONY: tag push clean container
|
.PHONY: tag push
|
||||||
all: push
|
|
||||||
|
|
||||||
# Build the virtsock stress server
|
|
||||||
VIRTSOCK_BINARY=bin/virtsock_stress
|
|
||||||
DEPS=Dockerfile.build Makefile
|
|
||||||
virtsock.tag: $(DEPS)
|
|
||||||
BUILD=$$(docker build -f $< -q .) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && echo "$$BUILD" > $@
|
|
||||||
|
|
||||||
$(VIRTSOCK_BINARY): virtsock.tag
|
|
||||||
mkdir -p $(dir $@)
|
|
||||||
docker run --rm --net=none --log-driver=none $(shell cat virtsock.tag) > $@
|
|
||||||
chmod ugo+x $@
|
|
||||||
|
|
||||||
TINI_IMAGE=linuxkit/tini:da0e068f8b537b81f817439a52f63e8f6d91cca3@sha256:bdca5e6703c9553d890c79a4a094e2f05df87f09f6bd5bef26c06d6cba56c112
|
|
||||||
TINI_BINARY=bin/tini
|
|
||||||
|
|
||||||
$(TINI_BINARY):
|
|
||||||
mkdir -p $(dir $@)
|
|
||||||
docker run --rm --net=none $(TINI_IMAGE) tar cf - $@ | tar xf -
|
|
||||||
|
|
||||||
SHASUM=alpine:3.5
|
|
||||||
IMAGE=test-virtsock
|
IMAGE=test-virtsock
|
||||||
container: Dockerfile.pkg $(DEPS) $(VIRTSOCK_BINARY) $(TINI_BINARY)
|
|
||||||
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -f $< -
|
|
||||||
|
|
||||||
hash: Dockerfile.pkg $(DEPS)
|
default: push
|
||||||
|
|
||||||
|
DEPS=Dockerfile Makefile
|
||||||
|
SHASUM=alpine:3.5
|
||||||
|
hash: $(DEPS)
|
||||||
find $^ -type f | xargs cat | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@
|
find $^ -type f | xargs cat | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@
|
||||||
|
|
||||||
push: hash container
|
tag: hash
|
||||||
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
|
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
|
||||||
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
|
(docker build --no-cache -t $(IMAGE):build . && \
|
||||||
docker push linuxkit/$(IMAGE):$(shell cat hash))
|
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash))
|
||||||
docker rmi $(IMAGE):build
|
docker rmi $(IMAGE):build || true
|
||||||
rm -f hash
|
|
||||||
|
|
||||||
tag: hash container
|
push: tag
|
||||||
docker pull linuxkit/$(IMAGE):$(shell cat 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
|
rm -f hash
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(VIRTSOCK_BINARY) $(TINI_BINARY) virtsock.tag hash
|
rm -rf hash
|
||||||
|
docker rmi $(IMAGE):build || true
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
|
@ -38,8 +38,11 @@ services:
|
|||||||
net: host
|
net: host
|
||||||
oomScoreAdj: -800
|
oomScoreAdj: -800
|
||||||
- name: virtsock-server
|
- name: virtsock-server
|
||||||
image: "linuxkit/test-virtsock:cd2135acdc225f3bd0503678bb50bbd3e0b194b2"
|
image: "linuxkit/test-virtsock:89133a5081b44dcda66e57502bcbc783e0a654be"
|
||||||
readonly: true
|
readonly: true
|
||||||
|
trust:
|
||||||
|
image:
|
||||||
|
- linuxkit/kernel
|
||||||
outputs:
|
outputs:
|
||||||
- format: kernel+initrd
|
- format: kernel+initrd
|
||||||
- format: iso-bios
|
- format: iso-bios
|
||||||
|
Loading…
Reference in New Issue
Block a user