fix(wger): set the database env vars the upstream image stopped shipping (#3044)

* fix(wger): set the database env vars the upstream image stopped shipping

wger/server:latest no longer defines DJANGO_DB_ENGINE or DJANGO_DB_DATABASE in
its image environment, and upstream settings/main.py reads both with no
fallback. Every fresh install therefore died at startup with
"ImproperlyConfigured: Set the DJANGO_DB_ENGINE environment variable".

Set both explicitly in the Dockerfile, pointing at the sqlite database in
/data/database.sqlite that the add-on already persists, and add
DJANGO_PERFORM_MIGRATIONS=True so an existing database picks up new migrations
when the image is rebuilt against a newer upstream release.

With the path now set through the environment, the cont-init rewrite of the
database path in the Python settings is dead code — upstream no longer
hardcodes /home/wger/db/database.sqlite anywhere, so it only logged a warning.

Also move the add-on to the addon_configs location, as the issue asks: the
shared 01-config_yaml.sh template migrates an existing
/homeassistant/addons_config/wger/config.yaml on the first start.

Fixes #3043

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(wger): use the ISO date format the rest of this CHANGELOG uses

The 2.6.4 heading was written 04-09-2026 while every other dated heading
in this file, and 22937 of the 23999 dated headings in the repo, use ISO
YYYY-MM-DD. Copilot flagged the inconsistency on #3044.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Alexandre
2026-09-05 07:49:00 +02:00
committed by GitHub
parent 296bb3767a
commit a237a6820c
4 changed files with 16 additions and 17 deletions

View File

@@ -1,3 +1,10 @@
## 2.6.4 (2026-09-04)
- Fix the add-on failing to start on a fresh install with `django.core.exceptions.ImproperlyConfigured: Set the DJANGO_DB_ENGINE environment variable`. The upstream `wger/server` image stopped shipping database defaults, and `settings/main.py` reads `DJANGO_DB_ENGINE` and `DJANGO_DB_DATABASE` with no fallback, so the add-on now sets them explicitly to sqlite at `/data/database.sqlite` — the same location the previous startup rewrite produced, so existing databases keep working.
- Set `DJANGO_PERFORM_MIGRATIONS=True`, as upstream's own docker deployment does, so an existing database gets new migrations applied when the add-on is rebuilt against a newer upstream release.
- Drop the startup rewrite of the database path in the Python settings: upstream no longer hardcodes `/home/wger/db/database.sqlite` anywhere, so the rewrite silently did nothing and only logged a warning.
- ⚠ MAJOR CHANGE : switch to the new config logic from homeassistant. Your configuration file will have migrated from /config/addons_config/wger to a folder only accessible from my Filebrowser addon called /addon_configs/xxx-wger. This avoids the addon to mess with your homeassistant configuration folder, and allows to backup the options. Migration is automatic only for a config.yaml sitting at the default /config/addons_config/wger/config.yaml. If you had pointed CONFIG_LOCATION somewhere else inside the homeassistant config folder, or had a custom script at /homeassistant/addons_autoscripts/wger.sh, move the file to /addon_configs/xxx-wger/ by hand and update the option. Please be sure to update all your links ! For more information, see here : https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/
## 2.6.3 (2026-08-01)
- Version renamed from `2.6-dev-3`, which Home Assistant could not order and therefore could not reliably offer as an update: every number of the previous version is kept, as a section of its own. The addon itself and the upstream version it tracks are unchanged

View File

@@ -28,9 +28,14 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_SERVICES_GRACETIME=0
# The upstream image no longer ships database defaults; settings/main.py reads
# DJANGO_DB_ENGINE and DJANGO_DB_DATABASE with no fallback, so they must be set here
ENV SYNC_EXERCISES_ON_STARTUP=True \
DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=True \
FROM_EMAIL='wger Workout Manager <wger@example.com>' \
DJANGO_DB_ENGINE="django.db.backends.sqlite3" \
DJANGO_DB_DATABASE="/data/database.sqlite" \
DJANGO_PERFORM_MIGRATIONS=True \
DJANGO_MEDIA_ROOT="/data/media" \
DJANGO_STATIC_ROOT="/data/static"

View File

@@ -5,12 +5,13 @@ description: manage your personal workouts, weight and diet plans
image: ghcr.io/alexbelgium/wger-{arch}
map:
- share:rw
- config:rw
- addon_config:rw
- homeassistant_config:rw
- ssl:ro
name: Wger
options:
env_vars: []
CONFIG_LOCATION: /config/addons_config/wger/config.yaml
CONFIG_LOCATION: /config/config.yaml
ports:
80/tcp: 9927
ports_description:
@@ -23,5 +24,5 @@ schema:
slug: wger
udev: true
url: https://github.com/alexbelgium/hassio-addons
version: "2.6.3"
version: "2.6.4"
webui: "[PROTO:ssl]://[HOST]:[PORT:80]"

View File

@@ -51,20 +51,6 @@ migrate_database() {
fi
}
############################
# Change database location #
############################
echo "... set database path"
mapfile -t SETTINGS_FILES < <(grep -rl --include='*.py' '/home/wger/db/database.sqlite' /home 2> /dev/null || true)
if [ "${#SETTINGS_FILES[@]}" -gt 0 ]; then
for settings_file in "${SETTINGS_FILES[@]}"; do
sed -i "s|/home/wger/db/database.sqlite|/data/database.sqlite|g" "$settings_file"
done
else
bashio::log.warning "Unable to find Python settings containing database path under /home, skipping rewrite"
fi
#####################
# Adapt directories #
#####################