Browse Source

docker: bring docker integration in to the main repo

by bringing the Dockerfile to the main repo we make sure that
a docker image is built everytime something is commited to
the master branch. A hypothetical user can come in and start
running harvey by

	docker run harveyos/harvey

R=fuchicar

Signed-off-by: Sevki <s@sevki.org>
Sevki 2 years ago
parent
commit
26d2963067
2 changed files with 52 additions and 0 deletions
  1. 12 0
      Dockerfile
  2. 40 0
      util/GO9PCPUDOCKER

+ 12 - 0
Dockerfile

@@ -0,0 +1,12 @@
+FROM alpine:3.5
+
+RUN apk update; apk add git git-perl go gcc bison musl-dev qemu qemu-system-x86_64 curl bash
+ENV HARVEY=/harvey ARCH=amd64 CC=gcc
+RUN adduser -S harvey && adduser -S none
+
+ADD . /harvey
+WORKDIR /harvey
+
+RUN ./bootstrap.sh && /harvey/util/build
+
+ENTRYPOINT ["/harvey/util/GO9PCPUDOCKER"]

+ 40 - 0
util/GO9PCPUDOCKER

@@ -0,0 +1,40 @@
+#!/bin/bash
+set -e
+
+trap : 2
+
+$HARVEY/util/ufs -root=$HARVEY &
+ufspid=$!
+
+export machineflag=q35
+if [ "$(uname)" = "Linux" ] && [ -e /dev/kvm ]; then
+	export kvmflag='-enable-kvm'
+	export machineflag='pc,accel=kvm'
+	if [ ! -w /dev/kvm ]; then
+		# we don't have access as a regular user
+		export kvmdo=sudo
+	fi
+fi
+
+read -r cmd <<EOF
+$kvmdo qemu-system-x86_64 -s -cpu Opteron_G1 -smp 4 -m 2048 $kvmflag \
+-nographic \
+--machine $machineflag \
+-net nic,model=rtl8139 \
+-net user,id=user.0,\
+hostfwd=tcp::5555-:1522,\
+hostfwd=tcp::9999-:9,\
+hostfwd=tcp::17010-:17010,\
+hostfwd=tcp::1666-:1666,\
+hostfwd=tcp::5356-:5356,\
+hostfwd=tcp::17013-:17013 \
+-net dump,file=/tmp/vm0.pcap \
+-append "service=cpu nobootprompt=tcp maxcores=1024 fs=10.0.2.2 auth=10.0.2.2 nvram=/boot/nvram nvrlen=512 nvroff=0 acpiirq=1" \
+-kernel $HARVEY/sys/src/9/amd64/harvey.32bit $*
+EOF
+
+echo $cmd
+eval $cmd
+
+kill $ufspid
+wait