Title: Running the packaged *arr stack on Alpine
Date: 2025-12-04 00:15

I've been running some parts of the [\*arr stack]( https://wiki.servarr.com/ )
on my hypervisor at home for quite some time now, but only recently did I
notice that they were [packaged in
Alpine](https://pkgs.alpinelinux.org/packages?name=*arr&branch=edge&repo=&arch=x86_64&origin=&flagged=&maintainer=)!
I trashed the container with all the carefully-deployed-by-hand binaries,
created a new one running [Alpine
Edge](https://wiki.alpinelinux.org/wiki/Repositories#Edge), ran `apk add sonarr
radarr prowlarr`, and…

```console
~ # apk add sonarr radarr prowlarr
ERROR: unable to select packages:
  aspnetcore6-runtime (no such package):
    required by: sonarr-4.0.16.2944-r0[aspnetcore6-runtime]
~ #
```

Urgh, the latest Sonarr release
([v4.0.16.2944](https://github.com/Sonarr/Sonarr/releases/tag/v4.0.16.2944)),
is still [running on .NET
6](https://github.com/Sonarr/Sonarr/blob/v4.0.16.2944/src/NzbDrone.Core/Sonarr.Core.csproj),
which isn't packaged anymore on Alpine Edge. Fortunately, one can do horribly
unsupported things like [mixing
repositories](https://wiki.alpinelinux.org/wiki/Repositories#Tagged_repository),
and have a `/etc/apk/repositories` frankenfile looking like this:

```
https://dl-cdn.alpinelinux.org/alpine/edge/main
https://dl-cdn.alpinelinux.org/alpine/edge/community
https://dl-cdn.alpinelinux.org/alpine/edge/testing

@main319 https://dl-cdn.alpinelinux.org/alpine/v3.19/main
@community319 https://dl-cdn.alpinelinux.org/alpine/v3.19/community
```

Installing Sonarr can then be done with `apk add sonar@community319
sonar-openrc@community319`, launched via `service sonarr start`, and … it
crashes after a couple of seconds. Running `service -d sonarr start` tells us
that the binary being launched is `/usr/lib/sonarr/bin/Sonarr`, so let's see
what happens when we run it manually:

```
~ $ /usr/lib/sonarr/bin/Sonarr
You must install or update .NET to run this application.

App: /usr/lib/sonarr/bin/Sonarr
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '6.0.36' (x64)
.NET location: /usr/lib/dotnet

The following frameworks were found:
  6.0.31 at [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
  8.0.22 at [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Learn more:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.36&arch=x64&rid=alpine.3.23-x64&os=alpine
~ $
```

Alright, .NET version mismatch: we have 6.0.31 installed and the binary wants
6.0.36. The
[`DOTNET_ROLL_FORWARD`](https://learn.microsoft.com/en-us/dotnet/core/versions/selection#framework-dependent-apps-roll-forward)
environment variable can be used to make a binary run on newer version of
the runtime, but not an older one. While we can't use 6.0.31, we have 8.0.22
installed for the rest of the \*arr stack, so let's give it a try. Adding 
`DOTNET_ROLL_FORWARD=LatestMajor` followed by `export DOTNET_ROLL_FORWARD`
in `/etc/init.d/sonarr` does the trick, and Sonarr is now working, huzzah!

Once [Sonarr 5.X](https://github.com/Sonarr/Sonarr/tree/v5-develop) is
released, I'll simply remove the `@community319/@main@319` lines from
`/etc/apk/repositories` and run `apk update; apk upgrade` to get the version
compiled for modern packaged .NET.

