From a237a6820c0c9f72162f046f7270139ae0529ee2 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 5 Sep 2026 07:49:00 +0200 Subject: [PATCH] fix(wger): set the database env vars the upstream image stopped shipping (#3044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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 --------- Co-authored-by: Claude Opus 5 --- wger/CHANGELOG.md | 7 +++++++ wger/Dockerfile | 5 +++++ wger/config.yaml | 7 ++++--- wger/rootfs/etc/cont-init.d/90-run.sh | 14 -------------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/wger/CHANGELOG.md b/wger/CHANGELOG.md index 7fb0a08e80..ee359908df 100644 --- a/wger/CHANGELOG.md +++ b/wger/CHANGELOG.md @@ -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 diff --git a/wger/Dockerfile b/wger/Dockerfile index 40c9c201cb..0e99e5ecbf 100644 --- a/wger/Dockerfile +++ b/wger/Dockerfile @@ -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 ' \ + 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" diff --git a/wger/config.yaml b/wger/config.yaml index 91230dc5a4..dd42132149 100644 --- a/wger/config.yaml +++ b/wger/config.yaml @@ -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]" diff --git a/wger/rootfs/etc/cont-init.d/90-run.sh b/wger/rootfs/etc/cont-init.d/90-run.sh index c4bef22433..d479f2e9a7 100755 --- a/wger/rootfs/etc/cont-init.d/90-run.sh +++ b/wger/rootfs/etc/cont-init.d/90-run.sh @@ -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 # #####################