Skip to content

Commit 2204d72

Browse files
committed
moving apptron vm definition here with gh actions builder
1 parent 83b2c14 commit 2204d72

File tree

5 files changed

+98
-0
lines changed

5 files changed

+98
-0
lines changed

.github/workflows/build-image.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
defaults:
9+
run:
10+
# GitHub Actions run without a TTY device. This is a workaround to get one,
11+
# based on https://github.com/actions/runner/issues/241#issuecomment-2019042651
12+
shell: 'script --return --quiet --log-out /dev/null --command "sh -e {0}"'
13+
14+
jobs:
15+
build-image:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
services:
20+
docker:
21+
image: docker:dind
22+
options: --privileged --shm-size=2g
23+
volumes:
24+
- /var/run/docker.sock:/var/run/docker.sock:ro
25+
container:
26+
image: progrium/env86:latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Create image
32+
run: |
33+
make vm
34+
tar -czf apptron-vm.tgz -C dist .
35+
36+
- uses: ncipollo/release-action@v1
37+
with:
38+
tag: "release"
39+
allowUpdates: true
40+
artifacts: "apptron-vm.tgz"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vm/image
2+
/dist

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.PHONY: vm
2+
3+
vm:
4+
rm -rf ./vm/image
5+
env86 create --with-guest --from-docker ./vm/Dockerfile ./vm/image
6+
env86 boot --cold --ttyS0 --save --no-console --exit-on="localhost:~#" ./vm/image
7+
rm -rf ./dist
8+
env86 prepare ./vm/image ./dist

vm/Dockerfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM i386/alpine:3.18.6
2+
3+
ENV KERNEL=lts
4+
ENV HOSTNAME=localhost
5+
ENV PASSWORD='root'
6+
7+
RUN apk add openrc \
8+
alpine-base \
9+
agetty \
10+
alpine-conf
11+
12+
# Install mkinitfs from edge (todo: remove this when 3.19+ has worked properly with 9pfs)
13+
RUN apk add mkinitfs --no-cache --allow-untrusted --repository https://dl-cdn.alpinelinux.org/alpine/edge/main/
14+
15+
RUN if [ "$KERNEL" == "lts" ]; then \
16+
apk add linux-lts \
17+
linux-firmware-none \
18+
linux-firmware-sb16; \
19+
else \
20+
apk add linux-$KERNEL; \
21+
fi
22+
23+
# Adding networking.sh script (works only on lts kernel yet)
24+
RUN if [ "$KERNEL" == "lts" ]; then \
25+
echo -e "echo '127.0.0.1 localhost' >> /etc/hosts && rmmod ne2k-pci && modprobe ne2k-pci\nhwclock -s\nsetup-interfaces -a -r" > /root/networking.sh && \
26+
chmod +x /root/networking.sh; \
27+
fi
28+
29+
RUN sed -i 's/getty 38400 tty1/agetty --autologin root tty1 linux/' /etc/inittab
30+
RUN echo 'ttyS0::once:/sbin/agetty --autologin root -s ttyS0 115200 vt100' >> /etc/inittab
31+
RUN echo "root:$PASSWORD" | chpasswd
32+
33+
# assume env86 will add /bin/guest86
34+
COPY ./guest86.service /etc/init.d/guest86
35+
# there is a bug where it always crashes on first run
36+
RUN echo "rc-service guest86 start && rc-service guest86 stop && rc-service guest86 start" > /root/.profile
37+
38+
# https://wiki.alpinelinux.org/wiki/Alpine_Linux_in_a_chroot#Preparing_init_services
39+
RUN for i in devfs dmesg mdev hwdrivers; do rc-update add $i sysinit; done
40+
RUN for i in hwclock modules sysctl hostname bootmisc; do rc-update add $i boot; done
41+
RUN rc-update add killprocs shutdown
42+
43+
# Generate initramfs with 9p modules
44+
RUN mkinitfs -F "ata base ide scsi virtio ext4 9p" $(cat /usr/share/kernel/$KERNEL/kernel.release)

vm/guest86.service

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/sbin/openrc-run
2+
command="/bin/guest86"
3+
command_background="yes"
4+
pidfile="/var/run/guest86.pid"

0 commit comments

Comments
 (0)