This is in prep for turning this into a HAOS (Home Assistant OS) app.
- Qemu
- Packer
- Docker
packer build uos_server.pkr.hcl- this will produce the VM image- on ARM macs, use
packer build -var host_is_arm_mac=true -var target_arch=arm64 uos_server.pkr.hcl
- on ARM macs, use
docker build . -t local/unifi-os-server- this will copy the VM image into a container image- for x86 builds to work, you probably have to pass
--build-arg BASE=qemux/qemu
- for x86 builds to work, you probably have to pass
Note: Building for other architectures than arm64 is not tested yet
Note: This requires support for nested virtualization in your Docker host
docker run -it --rm --name unifi-os-server --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 --sysctl net.ipv4.ip_forward=1 -p 11443:11443 local/unifi-os-server
To get nested virtualization working on ARM Macs, here are some tips:
-
Use Lima and start a VM with nested virtualization:
limactl start --set '.nestedVirtualization=true' template:docker export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')- enter the Lima shell:
limactl shell docker sudo usermod -G kvm $(whoami)sudo sh -c "echo '$(whoami):$(stat -c %g /dev/kvm):1' >> /etc/subgid"- leave shell
limactl restart docker
- enter the Lima shell:
-
now you can add
--group-add 1073741825to the docker run command and it should work