Fedora-bootc: how to install netbird

I’m trying to install netbird in a custom Fedora atomic image.

Here’s my Containerfile.

FROM quay.io/fedora/fedora-bootc:44

COPY <<EOF /etc/yum.repos.d/netbird.repo
[netbird]
name=netbird
baseurl=https://pkgs.netbird.io/yum/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.netbird.io/yum/repodata/repomd.xml.key
repo_gpgcheck=1
EOF

RUN <<EOF
set -ex

dnf install -y netbird

dnf clean all

bootc container lint
EOF

When I go to build it, I get this error.

$ podman build -t localhost/my-image:latest .
...
[3/3] Installing netbird-0:0.74.3-1.x86 100% | 172.0 MiB/s |  38.0 MiB |  00m00s
>>> Running %post scriptlet: netbird-0:0.74.3-1.x86_64
>>> Non-critical error in %post scriptlet: netbird-0:0.74.3-1.x86_64
>>> Scriptlet output:
>>>  Post Install of an clean install
>>> Error: install service: exit status 1
>>> Error: start service: exit status 1
>>> 
>>> [RPM] %post(netbird-0.74.3-1.x86_64) scriptlet failed, exit status 1
Transaction failed: Rpm transaction failed.
Error: building at STEP "RUN <<EOF": while running runtime: exit status 1

I’m guessing it’s failing on trying to start and/or enable the netbird systemd unit file? Is there a way to tell dnf to not attempt that?

Debugging update.

Oh. I guess this is more of a netbird packaging issue… I found how they build the RPM file: netbird/.goreleaser.yaml at main · netbirdio/netbird · GitHub

And they have a post install script.

    scripts:
      postinstall: "release_files/post_install.sh"
      preremove: "release_files/pre_remove.sh"

And this is the post install script file: netbird/release_files/post_install.sh at main · netbirdio/netbird · GitHub which calls

    /usr/bin/netbird service uninstall 2> /dev/null || true
    /usr/bin/netbird service install
    /usr/bin/netbird service start

OK, I figured out how to disable the scripts: https://unix.stackexchange.com/questions/599011/how-do-i-remove-a-package-with-a-failing-scriptlet-in-fedora-32

dnf --setopt=tsflags=noscripts install -y netbird

I got netbird installed with this Containerfile. :tada:

FROM quay.io/fedora/fedora-bootc:44

# From the netbird installation page
COPY <<EOF /etc/yum.repos.d/netbird.repo
[netbird]
name=netbird
baseurl=https://pkgs.netbird.io/yum/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.netbird.io/yum/repodata/repomd.xml.key
repo_gpgcheck=1
EOF

# From another computer, where I already had netbird installed.
COPY <<EOF /etc/systemd/system/netbird.service
[Unit]
Description=NetBird mesh network client
ConditionFileIsExecutable=/usr/bin/netbird
After=network.target syslog.target

[Service]
StartLimitInterval=5
StartLimitBurst=10

ExecStart=/usr/bin/netbird "service" "run" "--log-level" "info" "--daemon-addr" "unix:///var/run/netbird.sock" "--log-file" "/var/log/netbird/client.log"

Restart=always
RestartSec=120
EnvironmentFile=-/etc/sysconfig/netbird
Environment=SYSTEMD_UNIT=netbird

[Install]
WantedBy=multi-user.target
EOF

RUN <<EOF
set -ex

dnf --setopt=tsflags=noscripts install -y netbird
systemctl enable netbird.service

dnf clean all

rm -rf /run/dnf/ /var/log/dnf5.log /var/cache/libdnf5/ /var/lib/dnf/

bootc container lint
EOF

Then I built and pushed the image.

podman build ...
podman push

And on the target computer.

# Not sure if this step was necessary... bootc might pull too... idk.
podman pull <reg>/my-image:latest

sudo bootc switch <reg>/my-image:latest

# Verified that my image was staged.
sudo bootc status

sudo reboot

And later when you publish a new :latest, you run this.

sudo bootc upgrade