The document was written to build Incus v0.5.1. You may need a different how-to if you want to build higher versions of Incus.
- Incus v0.5.1 (via Git)
- AlpineLinux 3.18 x86_64
- Canonical LXD-UI (Via Git)
This how-to document will help you to build Incus for AlpineLinux. Original references are:
- https://linuxcontainers.org/incus/docs/main/installing/#from-source-build-a-release
- https://gist.github.com/seia-soto/28e8cd3763aa1c018d69f6bdd99bb6be
- https://github.com/canonical/lxd-ui/wiki/Build-the-UI-for-Arch-and-other-Linux-Distributions
- https://stgraber.org/2023/11/25/adding-a-web-ui-to-the-incus-demo-service/
- Figure out how to run this as a daemon user instead of manually from the CLI...
- Figure out how the SystemD services work on the Incus Debian packages and use this as a reference for creating Alpine OpenRC services
- ...figure out how to package this properly :) go easy it's my first time outside of debian
alpine-sdk
includes common dependencies for building programs such as git
.
You may remove unused dependencies or install required dependencies manually.
I haven't checked what's required explicitly.
apk add alpine-sdk xz acl-dev autoconf automake eudev-dev gettext-dev go intltool libcap-dev libtool libuv-dev linux-headers lz4-dev tcl-dev sqlite-dev lxc-dev
Incus replaced some Canonical tools with community fork.
For example, cowsql
is a community fork of dqlite
.
You'll also need following dependencies for incusd
to run correctly:
apk add rsync squashfs-tools iptables ip6tables acl attr ca-certificates cgmanager dbus dnsmasq iproute2 netcat-openbsd shadow-uidmap tar lxc libintl xz
Storage driver dependencies
apk add lvm2 thin-provisioning-tools
# activate dm-mod module
modprobe dm-mod
echo dm-mod >> /etc/modules-load.d/dm.conf
git clone https://github.com/lxc/incus
cd incus
git checkout v0.5.1
Build dependencies
# cc1: error: /usr/local/include: No such file or directory [-Werror=missing-include-dirs]
mkdir -p /usr/local/include
make deps
You'll see some environment variable definitions after make deps
completes.
Paste the export
commands into your console.
Build Incus
Now you can build Incus.
# gettext.cgo2.c:(.text+0x2b9): undefined reference to `libintl_gettext'
# - module path: https://pkgs.alpinelinux.org/contents?file=libintl*&path=&name=gettext-dev&branch=edge
# - related issue: https://github.com/gosexy/gettext/issues/1
export CGO_LDFLAGS="$CGO_LDFLAGS -L/usr/lib -lintl"
export CGO_CPPFLAGS="-I/usr/include"
make
I copied some commands to keep v0.5.1
installation docs here.
If you're installing higher versions of Incus, please check the original documentation.
Setup environment variables
You can put following lines to console, or add them in /etc/profile.d/99incus.sh
for global environment setup.
export PATH="${PATH}:$(go env GOPATH)/bin"
export LD_LIBRARY_PATH="$(go env GOPATH)/deps/cowsql/.libs/:$(go env GOPATH)/deps/raft/.libs/:${LD_LIBRARY_PATH}"
Setup unprivileged containers
echo "root:1000000:1000000000" | sudo tee -a /etc/subuid /etc/subgid
Disable QEMU (Optional!)
Maybe you are running Incus on a potato. In my case I run it on extremely low-end atom hardware, after all, I just wanted containers. In such a case, and without installing QEMU dependencies, you will receive the following error at startup:
WARNING[2024-02-06T21:17:04Z] Instance type not operational driver=qemu err="KVM support is missing (no /dev/kvm)" type=virtual-machine
To resolve:
vim internal/server/instance/drivers/load.go
Find lines 24-28:
// Instance driver definitions.
var instanceDrivers = map[string]func() instance.Instance{
"lxc": func() instance.Instance { return &lxc{} },
"qemu": func() instance.Instance { return &qemu{} },
}
Comment 26 and 27 as follows:
// Instance driver definitions.
var instanceDrivers = map[string]func() instance.Instance{
"lxc": func() instance.Instance { return &lxc{} }//,
// "qemu": func() instance.Instance { return &qemu{} },
}
Start daemon
sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(go env GOPATH)/bin/incusd --group wheel
Initial config
incus admin init
Installing Canonical's LXD-UI (Optional) Install deps for the UI
sudo apk add yarn npm
Build the UI
cd ~
git clone [email protected]:canonical/lxd-ui.git
cd lxd-ui
yarn && yarn build
cp -R build/ui /opt/incus/
ls /opt/incus/ui/
**assets** index.html
export INCUS_UI=/opt/incus/ui
Now restart incusd. Ensure the environment variable is set when you do so.
I didn't de-brand it. If that's of importance to you, look at these:
https://github.com/zabbly/incus/blob/daily/patches/ui-canonical-0001-Branding.patch
https://github.com/zabbly/incus/blob/daily/patches/ui-canonical-0002-Update-navigation.patch
https://github.com/zabbly/incus/blob/daily/patches/ui-canonical-0003-Update-certificate-generation.patch
https://github.com/zabbly/incus/blob/daily/patches/ui-canonical-0004-Remove-external-links.patch
https://github.com/zabbly/incus/blob/daily/patches/ui-canonical-0005-Remove-Canonical-image-servers.patch