tools: Build qemu package from the Alpine base

Also use the git tree hash as the hash.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-05-30 15:16:42 +01:00
parent 63d5031035
commit fa9151cc00
3 changed files with 25 additions and 37 deletions

View File

@ -1,15 +1,19 @@
FROM alpine:edge
COPY repositories /etc/apk/
RUN \
apk update && apk upgrade && \
apk add --no-cache \
FROM linuxkit/alpine:5240cbd9cf371c8211c8f1968e57c51a32098c8f AS mirror
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN apk add --no-cache --initdb -p /out \
alpine-baselayout \
busybox \
libarchive-tools \
qemu-img \
qemu-system-arm \
qemu-system-x86_64 \
ovmf@testing \
&& true
qemu-system-x86_64
RUN mkdir -p /out/usr/share/ovmf \
&& cp /usr/share/ovmf/bios.bin /out/usr/share/ovmf/bios.bin
RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache
FROM scratch
ENTRYPOINT []
CMD []
WORKDIR /
COPY --from=mirror /out/ /
COPY . .

View File

@ -1,29 +1,15 @@
.PHONY: tag push
BASE=alpine:3.5
IMAGE=qemu
default: push
hash: Dockerfile repositories
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --rm --entrypoint /bin/sh $(IMAGE):build -c 'cat Dockerfile /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > $@
ORG?=linuxkit
IMAGE=qemu
DEPS=Dockerfile Makefile
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
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
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
tag: $(DEPS)
DOCKER_CONTENT_TRUST=1 docker build --no-cache --network=none -t $(ORG)/$(IMAGE):$(HASH) .
clean:
rm -f hash
.DELETE_ON_ERROR:
push: tag
docker pull $(ORG)/$(IMAGE):$(HASH) || \
docker push $(ORG)/$(IMAGE):$(HASH)

View File

@ -1,2 +0,0 @@
http://dl-cdn.alpinelinux.org/alpine/edge/main
@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing