Switch from Docker to vagrant

This commit is contained in:
Micah Lee 2021-06-28 19:27:49 -07:00
parent c6bb676ce2
commit c25220a767
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
5 changed files with 35 additions and 49 deletions

View file

@ -1 +1,2 @@
vm vm
.vagrant

View file

@ -1,13 +1,12 @@
# Build the Dangerzone VM for running podman # Build the Dangerzone VM for running podman
## Build the podman container storage (with vagrant) ## Build the ISO
You need vagrant: `brew install vagrant` You need vagrant: `brew install vagrant`
## Build the ISO image (with docker)
```sh ```sh
docker run -v $(pwd):/build alpine:latest /build/build-iso.sh vagrant up
vagrant ssh -- /vagrant/build-iso.sh
``` ```
## Run the VM ## Run the VM
@ -21,3 +20,5 @@ You can ssh in as the unprivileged user like this:
```sh ```sh
ssh -i ./ssh-key/id_ed25519 -o StrictHostKeyChecking=no user@192.168.65.3 ssh -i ./ssh-key/id_ed25519 -o StrictHostKeyChecking=no user@192.168.65.3
``` ```
(doesn't work yet)

View file

@ -4,7 +4,7 @@
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.box = "generic/alpine313" config.vm.box = "generic/alpine313"
config.vm.synced_folder "../../dangerzone-converter", "/opt/dangerzone-converter" config.vm.synced_folder "../../dangerzone-converter", "/opt/dangerzone-converter"
config.vm.synced_folder ".", "/opt/build" config.vm.synced_folder ".", "/vagrant"
config.vm.provision "shell", inline: <<-SHELL config.vm.provision "shell", inline: <<-SHELL
apk update apk update
apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs-tools sudo apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs-tools sudo

View file

@ -1,60 +1,48 @@
#!/bin/sh #!/bin/sh
# Following: https://wiki.alpinelinux.org/wiki/How_to_make_a_custom_ISO_image_with_mkimage cd ~/
# Install dependencies # Add build user
apk update sudo adduser build -D -G abuild
apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs-tools sudo sudo sh -c 'echo "%abuild ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/abuild'
apk add mtools dosfstools grub-efi
apk add p7zip
# Create a new user
adduser build -D -G abuild
echo "%abuild ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/abuild
cat << EOF > /home/build/go.sh
#!/bin/sh
cd /home/build
# Create signing keys # Create signing keys
abuild-keygen -i -a -n sudo -u build abuild-keygen -i -a -n
# Setup aports # Setup aports
wget https://gitlab.alpinelinux.org/alpine/aports/-/archive/master/aports-master.tar.gz if [ -d aports ]; then
tar -xf aports-master.tar.gz echo "already downloaded"
mv aports-master aports else
cp /build/mkimg.dangerzone.sh aports/scripts/ wget https://gitlab.alpinelinux.org/alpine/aports/-/archive/master/aports-master.tar.gz
cp /build/genapkovl-dangerzone.sh aports/scripts/ tar -xf aports-master.tar.gz
chmod +x aports/scripts/mkimg.dangerzone.sh mv aports-master aports
chmod +x aports/scripts/genapkovl-dangerzone.sh fi
cp /vagrant/mkimg.dangerzone.sh ~/aports/scripts/
cp /vagrant/genapkovl-dangerzone.sh ~/aports/scripts/
chmod +x ~/aports/scripts/mkimg.dangerzone.sh
chmod +x ~/aports/scripts/genapkovl-dangerzone.sh
# Set up the vm dir
rm -r /vagrant/vm
mkdir -p /vagrant/vm
chmod 777 /vagrant/vm
# Make the iso # Make the iso
cd aports/scripts cd ~/aports/scripts
sh mkimage.sh --tag v3.14 \ sudo -u build sh mkimage.sh --tag v3.14 \
--outdir /build/vm \ --outdir /vagrant/vm \
--arch x86_64 \ --arch x86_64 \
--repository http://dl-cdn.alpinelinux.org/alpine/v3.14/main \ --repository http://dl-cdn.alpinelinux.org/alpine/v3.14/main \
--repository http://dl-cdn.alpinelinux.org/alpine/v3.14/community \ --repository http://dl-cdn.alpinelinux.org/alpine/v3.14/community \
--profile dangerzone --profile dangerzone
EOF
chmod +x /home/build/go.sh
# Set up the vm dir
rm -r /build/vm
mkdir -p /build/vm
chmod 777 /build/vm
# Start the build
sudo -u build /home/build/go.sh
# Fix permissions # Fix permissions
chmod 755 /build/vm chown -R vagrant:vangrant /vagrant/vm
chmod 644 /build/vm/* chmod 755 /vagrant/vm
chown root:root /build/vm/* chmod 644 /vagrant/vm/*
# Extract vmlinuz and initramfs # Extract vmlinuz and initramfs
cd /build/vm cd /vagrant/vm
7z x alpine-dangerzone-v3.14-x86_64.iso boot/vmlinuz-virt 7z x alpine-dangerzone-v3.14-x86_64.iso boot/vmlinuz-virt
7z x alpine-dangerzone-v3.14-x86_64.iso boot/initramfs-virt 7z x alpine-dangerzone-v3.14-x86_64.iso boot/initramfs-virt
mv boot/* . mv boot/* .

View file

@ -1,4 +0,0 @@
#!/bin/sh
# TODO: create podman user
# TODO: set /home/podman/.ssh/authorized_keys