## Building mirage-www unikernel on Ubuntu 22.04 LTS 1. Clone the mirage-www repository on the Raspberry Pi: ``` $ git clone https://github.com/mirage/mirage-www.git ``` 2. Update opam: ``` $ sudo bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)" $ opam init $ opam update && opam upgrade $ opam switch create 4.14.0 ocaml-base-compiler.4.14.0 ``` 3. Install mirage: ``` $ opam repo add mirage-dev https://github.com/mirage/mirage-dev.git $ opam install "mirage>=4.0.0" ``` 4. Configure the unikernel: ``` $ cd mirage-www $ mirage configure -f mirage/config.ml -t hvt ``` 5. Pin tailwind css: ``` $ opam pin git+https://github.com/tmattio/opam-tailwindcss.git ``` 6. Fetch the dependencies: ``` $ make depends ``` Answer yes to `Opam plugin “monorepo” may require upgrading/reinstalling. Reinstall the plugin on the current switch? [Y/n] y`. 7. Build the unikernel: ``` $ dune build mirage/ ``` 8. Expose port 80 in the iptables firewall: ``` $ sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 10.0.0.2:80 ``` You can also add the above iptables entry to `bridge.sh` script so that everytime you reboot and run bridge.sh script, the firewall is updated. ``` iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 10.0.0.2:80 ``` If running on your computer, create the tap0 interface: ``` $ sudo ip tuntap add tap0 mode tap $ sudo ip addr add 10.0.0.1/24 dev tap0 $ sudo ip link set dev tap0 up ``` 9. Run bridge.sh script ``` $ sudo ~/bridge.sh ``` 10. Run the mirage-www unikernel: ``` $ solo5-hvt --net:service=tap0 -- ./mirage/dist/www.hvt --ipv4-gateway=10.0.0.1 ``` You can open a browser on your system/laptop with IP address of the Raspberry Pi and default port 80, and you should be able to see the mirage-www htdocs. ## Reference 1. MirageOS Unikernel. https://github.com/mirage/mirage-www/#mirageos-unikernel