Self Hosting Wger in my FreeBSD Jail

2024-12-24

Table of Contents:

Update: the server software stack is a mess to maintain, I have given up

Wger is a nice workout manager, to track your workout history and sets.

While cool, the central server is in Germany and accessing takes a significant amount of time. So I decided to self-host it and use my own version.

I'm using wger in a FreeBSD thin jail, in order to separate the dependencies and ease management.

Jail configuration

Follow FreeBSD handbook on creating a thin jail with zfs[1], and use the following configuration:

wger {
    # STARTUP/LOGGING
    exec.start = "/bin/sh /etc/rc";
    exec.stop = "/bin/sh /etc/rc.shutdown";
    exec.consolelog = "/var/log/jail_console_${name}.log";
    # PERMISSIONS
    allow.raw_sockets;
    exec.clean;
    mount.devfs;
    # HOSTNAME/PATH
    host.hostname = "${name}";
    path = "/usr/local/jails/containers/${name}";
    # NETWORK
    ip4 = inherit;
    interface = em0;
}

Start it up with service jail start wger

Add a user wger to run and manage the service:

jexec -l wger adduser -w no

Security

Append kern.racct.enable=1 to /boot/loader.conf to enable rctl, and use it to limit the Jail resourse usage to prevent DDOS:

# /etc/rctl.conf
jail:wger:memoryuse:deny=4G/jail
jail:wger:pcpu:deny=4/jail

Install dependencies

Dependencies

According to the wiki of wger, you need the following packages[2]:

pkg -j wger install node npm git cairo yarn python311-pip rust
jexec -l wger npm install -g sass
pkg -j wger install ap24-py311-mod_wsgi

Optional dependency for video:

pkg -j wger install py311-ffmpeg-python

Setup python and git repo

python3.11 -m venv venv-wger
. venv-wger/bin/activate

git clone https://github.com/wger-project/wger.git src
cd src

pip install --upgrade pip
pip install -r requirements_prod.txt
pip install -e .

  1. FreeBSD Handbook page

  2. Wger wiki page