-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving apptron vm definition here with gh actions builder
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Build Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
# GitHub Actions run without a TTY device. This is a workaround to get one, | ||
# based on https://github.com/actions/runner/issues/241#issuecomment-2019042651 | ||
shell: 'script --return --quiet --log-out /dev/null --command "sh -e {0}"' | ||
|
||
jobs: | ||
build-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
services: | ||
docker: | ||
image: docker:dind | ||
options: --privileged --shm-size=2g | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock:ro | ||
container: | ||
image: progrium/env86:latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create image | ||
run: | | ||
make vm | ||
tar -czf apptron-vm.tgz -C dist . | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
tag: "release" | ||
allowUpdates: true | ||
artifacts: "apptron-vm.tgz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/vm/image | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.PHONY: vm | ||
|
||
vm: | ||
rm -rf ./vm/image | ||
env86 create --with-guest --from-docker ./vm/Dockerfile ./vm/image | ||
env86 boot --cold --ttyS0 --save --no-console --exit-on="localhost:~#" ./vm/image | ||
rm -rf ./dist | ||
env86 prepare ./vm/image ./dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM i386/alpine:3.18.6 | ||
|
||
ENV KERNEL=lts | ||
ENV HOSTNAME=localhost | ||
ENV PASSWORD='root' | ||
|
||
RUN apk add openrc \ | ||
alpine-base \ | ||
agetty \ | ||
alpine-conf | ||
|
||
# Install mkinitfs from edge (todo: remove this when 3.19+ has worked properly with 9pfs) | ||
RUN apk add mkinitfs --no-cache --allow-untrusted --repository https://dl-cdn.alpinelinux.org/alpine/edge/main/ | ||
|
||
RUN if [ "$KERNEL" == "lts" ]; then \ | ||
apk add linux-lts \ | ||
linux-firmware-none \ | ||
linux-firmware-sb16; \ | ||
else \ | ||
apk add linux-$KERNEL; \ | ||
fi | ||
|
||
# Adding networking.sh script (works only on lts kernel yet) | ||
RUN if [ "$KERNEL" == "lts" ]; then \ | ||
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 && \ | ||
chmod +x /root/networking.sh; \ | ||
fi | ||
|
||
RUN sed -i 's/getty 38400 tty1/agetty --autologin root tty1 linux/' /etc/inittab | ||
RUN echo 'ttyS0::once:/sbin/agetty --autologin root -s ttyS0 115200 vt100' >> /etc/inittab | ||
RUN echo "root:$PASSWORD" | chpasswd | ||
|
||
# assume env86 will add /bin/guest86 | ||
COPY ./guest86.service /etc/init.d/guest86 | ||
# there is a bug where it always crashes on first run | ||
RUN echo "rc-service guest86 start && rc-service guest86 stop && rc-service guest86 start" > /root/.profile | ||
|
||
# https://wiki.alpinelinux.org/wiki/Alpine_Linux_in_a_chroot#Preparing_init_services | ||
RUN for i in devfs dmesg mdev hwdrivers; do rc-update add $i sysinit; done | ||
RUN for i in hwclock modules sysctl hostname bootmisc; do rc-update add $i boot; done | ||
RUN rc-update add killprocs shutdown | ||
|
||
# Generate initramfs with 9p modules | ||
RUN mkinitfs -F "ata base ide scsi virtio ext4 9p" $(cat /usr/share/kernel/$KERNEL/kernel.release) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/sbin/openrc-run | ||
command="/bin/guest86" | ||
command_background="yes" | ||
pidfile="/var/run/guest86.pid" |