Merge pull request #874 from justincormack/gce-image

Build a GCE image
This commit is contained in:
Justin Cormack 2016-12-13 16:57:48 -08:00 committed by GitHub
commit e4c8845091
10 changed files with 122 additions and 1 deletions

7
Dockerfile.qemugce Normal file
View File

@ -0,0 +1,7 @@
# Tag: 804b2c40d078287c40aeb9166e475e843544e597
FROM mobylinux/alpine-qemu@sha256:aaecc961a62b14ee0ecd3a4fe792af5232637f0a49f7d0f90b87acaeb6f3fa4a
COPY alpine/gce.img.tar.gz .
RUN zcat gce.img.tar.gz | tar xf -
ENTRYPOINT [ "qemu-system-x86_64", "-serial", "stdio", "-drive", "file=disk.raw,format=raw", "-m", "2048", "-vnc", "none" ]

View File

@ -21,6 +21,10 @@ qemu-iso: Dockerfile.qemuiso alpine/mobylinux-bios.iso
tar cf - $^ | docker build -f Dockerfile.qemuiso -t mobyqemuiso:build - tar cf - $^ | docker build -f Dockerfile.qemuiso -t mobyqemuiso:build -
docker run -it --rm mobyqemuiso:build docker run -it --rm mobyqemuiso:build
qemu-gce: Dockerfile.qemugce alpine/gce.img.tar.gz
tar cf - $^ | docker build -f Dockerfile.qemugce -t mobyqemugce:build -
docker run -it --rm mobyqemugce:build
hyperkit.git: hyperkit.git:
git clone https://github.com/docker/hyperkit.git hyperkit.git git clone https://github.com/docker/hyperkit.git hyperkit.git

1
alpine/.gitignore vendored
View File

@ -2,6 +2,7 @@
*.tag *.tag
*.iso *.iso
*.vhd *.vhd
*.tar.gz
/mobylinux-boot.vhdx /mobylinux-boot.vhdx
/mobylinux.efi /mobylinux.efi
etc/moby-commit etc/moby-commit

View File

@ -16,6 +16,9 @@ BIOS_IMAGE=mobylinux/mkimage-iso-bios@sha256:7e28f7745fd62284142dce59a137c3331f7
# Tag: 95d4fef1a9555b640b4f94a4a3968533714059fe # Tag: 95d4fef1a9555b640b4f94a4a3968533714059fe
PAD4_IMAGE=mobylinux/pad4@sha256:a26e02f16bdafa241a55e05fa09b9bb260e69a3a8c90418bb40b4ae936437d17 PAD4_IMAGE=mobylinux/pad4@sha256:a26e02f16bdafa241a55e05fa09b9bb260e69a3a8c90418bb40b4ae936437d17
# Tag: df1b8ef666d66694e84f23772937ff45c46fa6c1
GCE_IMAGE=mobylinux/mkimage-gce@sha256:b19ba24184ed5602df5b666ed475d5d7211fa67bee51d3e6380cf0380c63f65b
moby.img: Dockerfile mkinitrd.sh init $(ETCFILES) moby.img: Dockerfile mkinitrd.sh init $(ETCFILES)
$(MAKE) -C kernel $(MAKE) -C kernel
$(MAKE) -j -C packages $(MAKE) -j -C packages
@ -76,7 +79,13 @@ mobylinux-efi.iso: Dockerfile.efi initrd.img kernel/x86_64/vmlinuz64
mobylinux-bios.iso: initrd.img kernel/x86_64/vmlinuz64 mobylinux-bios.iso: initrd.img kernel/x86_64/vmlinuz64
tar cf - initrd.img -C kernel/x86_64 vmlinuz64 | \ tar cf - initrd.img -C kernel/x86_64 vmlinuz64 | \
docker run --rm --net=none --log-driver=none -i $(BIOS_IMAGE) >$@ docker run --rm --net=none --log-driver=none -i $(BIOS_IMAGE) >$@
gce: gce.img.tar.gz
gce.img.tar.gz: common
tar cf - initrd.img -C kernel/x86_64 vmlinuz64 | \
docker run --rm --net=none --log-driver=none -i $(GCE_IMAGE) >$@
common: initrd.img common: initrd.img
$(MAKE) -C kernel $(MAKE) -C kernel

View File

@ -0,0 +1,4 @@
FROM debian:jessie
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -yq upgrade && apt-get install -yq libguestfs-tools syslinux linux-image-amd64 vim

View File

@ -0,0 +1,29 @@
.PHONY: tag push
BASE=debian:jessie
IMAGE=guestfs
default: push
hash: Dockerfile
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --rm $(IMAGE):build sh -c 'apt list --installed 2>/dev/null | sha1sum' | sed 's/ .*//' > hash
push: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
docker push mobylinux/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@ -0,0 +1,10 @@
# Tag: 8719f0f33b3cf9d59a62be64a42220978ac96486
FROM mobylinux/guestfs@sha256:c7229f01c1a54270d2bc3597c30121628c18db211ed32fb7202823b6eaa4f853
WORKDIR /tmp/image
COPY . .
COPY make-gce /usr/bin
CMD [ "/usr/bin/make-gce" ]

View File

@ -0,0 +1,27 @@
.PHONY: tag push
IMAGE=mkimage-gce
default: push
hash: Dockerfile make-gce syslinux.cfg
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --rm $(IMAGE):build sh -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash
push: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
docker push mobylinux/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@ -0,0 +1,25 @@
#!/bin/sh
set -e
# input is a tarball of vmlinuz64 and initrd.img on stdin
# output is a compressed tarball of a raw disk image on stdout
mkdir -p files
tar xf - -C files
cp syslinux.cfg files
tar cf files.tar -C files .
virt-make-fs --size=1G --type=ext4 --partition files.tar disk.raw
guestfish -a disk.raw -m /dev/sda1 <<EOF
upload /usr/lib/SYSLINUX/mbr.bin /mbr.bin
copy-file-to-device /mbr.bin /dev/sda size:440
rm /mbr.bin
extlinux /
part-set-bootable /dev/sda 1 true
EOF
tar cf - disk.raw | gzip -9

View File

@ -0,0 +1,5 @@
DEFAULT linux
LABEL linux
KERNEL /vmlinuz64
INITRD /initrd.img
APPEND earlyprintk=ttyS0,115200 console=ttyS0,115200