Giter Club home page Giter Club logo

docker's Introduction

wger logo

Production...ish docker compose image for wger

Usage

This docker compose file starts up a production environment with gunicorn as the webserver, postgres as a database and redis for caching with nginx used as a reverse proxy. If you want to develop, take a look at the docker compose file in the application repository.

The database, static files and uploaded images are mounted as volumes so the data is persisted. The only thing you need to do is update the docker images. Consult the docker volume command for details on how to access or backup this data.

It is recommended to regularly pull the latest version of the images from this repository, since sometimes new configurations or environmental variables are added.

Configuration

Instead of editing the compose file or the env file directly, it is recommended to extend it. That way you can more easily pull changes from this repository.

For example, you might not want to run the application on port 80 because some other service in your network is already using it. For this, simply create a new file called docker-compose.override.yml with the following content:

services:
  nginx:
    ports:
      - "8080:80"

Now the port setting will be overwritten from the configured nginx service when you do a docker compose up. However, note that compose will concatenate both sets of values so in this case the application will be binded to 8080 (from the override) and 80 (from the regular compose file). It seems that at the moment the only workaround is remove the ports settings altogether from the compose file.

The same applies to the env variables, just create a new file called e.g. my.env and add it after the provided prod.env for the web service (again, this is docker-compose.override.yml). There you add the settings that you changed, and only those, which makes it easier to troubleshoot, etc.:

web:
  env_file:
    - ./config/prod.env
    - ./config/my.env

To add a web interface for the celery queue, add a new service to the override file:

celery_flower:
  image: wger/server:latest
  container_name: wger_celery_flower
  command: /start-flower
  env_file:
    - ./config/prod.env
  ports:
    - "5555:5555"
  healthcheck:
    test: wget --no-verbose --tries=1 http://localhost:5555/healthcheck
    interval: 10s
    timeout: 5s
    retries: 5
  depends_on:
    celery_worker:
      condition: service_healthy

For more information and possibilities consult https://docs.docker.com/compose/extends/

1 - Start

To start all services:

docker compose up -d

Optionally download current exercises, exercise images and the ingredients from wger.de. Please note that load-online-fixtures will overwrite any local changes you might have while sync-ingredients should be used afterward once you have imported the initial fixtures:

docker compose exec web python3 manage.py sync-exercises
docker compose exec web python3 manage.py download-exercise-images
docker compose exec web python3 manage.py download-exercise-videos

docker compose exec web wger load-online-fixtures
# afterwards:
docker compose exec web python3 manage.py sync-ingredients

(these steps are configured by default to run regularly in the background, but can also run on startup as well, see the options in prod.env.)

Then open http://localhost (or your server's IP) and log in as: admin, password adminadmin

2 - Update the application

Just remove the containers and pull the newest version:

docker compose down
docker compose pull
docker compose up

3 - Lifecycle Management

To stop all services issue a stop command, this will preserve all containers and volumes:

docker compose stop

To start everything up again:

docker compose start

To remove all containers (except for the volumes)

docker compose down

To view the logs:

docker compose logs -f

You might need to issue other commands or do other manual work in the container, e.g.

 docker compose exec web yarn install
 docker compose exec --user root web /bin/bash
 docker compose exec --user postgres db psql wger -U wger

Deployment

The easiest way to deploy this application is to use a reverse proxy like nginx or traefik. You can change the port this application exposes and reverse proxy your domain to it. For this just edit the "nginx" service in docker-compose.yml and set the port to some value, e.g. "8080:80" then configure your proxy to forward requests to it, e.g. for nginx (no other ports need to be changed, they are used only within the application's docker network):

Also notice that the application currently needs to run on its own (sub)domain and not in a subdirectory, so location /wger { will probably only mostly work.

upstream wger {
    server 123.456.789.0:8080;
}

server {
    listen 80;
    listen [::]:443 ssl;
    listen 443 ssl;

    location / {
        proxy_pass http://wger;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
    }

    server_name my.domain.example.com;

    ssl_certificate /path/to/https/certificate.crt;
    ssl_certificate_key /path/to/https/certificate.key;
}

If you get CSRF errors

If you want to use HTTPS like in the example config you need to add some additional configurations. Since the HTTPS connections are reversed proxied, the secure connection terminates there, the application will receive a regular HTTP request and django's CSRF protection will kick in.

To solve this, update the env file and either

  • manually set a list of your domain names and/or server IPs CSRF_TRUSTED_ORIGINS=https://my.domain.example.com,https://118.999.881.119 If you are unsure what origin to add here, set the debug setting to true, restart and try again, the error message that appears will have the origin prominently displayed.
  • or set the X-Forwarded-Proto header like in the example and set X_FORWARDED_PROTO_HEADER_SET=True. If you do this consult the documentation as there are some security considerations.

You might want to set DJANGO_DEBUG to true while you are debugging this is you encounter errors.

Automatically start service

If everything works correctly, you will want to start the compose file as a service so that it auto restarts when you reboot the server. If you use systemd, this can be done with a simple file. Create the file /etc/systemd/system/wger.service and enter the following content (check where the absolute path of the docker command is with which docker)

[Unit]
Description=wger docker compose service
PartOf=docker.service
After=docker.service

[Service]
Type=oneshot
RemainAfterExit=true
WorkingDirectory=/path/to/the/docker/compose/
ExecStart=/usr/bin/docker compose up -d --remove-orphans
ExecStop=/usr/bin/docker compose down

[Install]
WantedBy=multi-user.target

Read the file with systemctl daemon-reload and start it with systemctl start wger. If there are no errors and systemctl status wger shows that the service is active (this might take some time), everything went well. With systemctl enable wger the service will be automatically restarted after a reboot.

Backup

Database volume: The most important thing to backup. For this just make a dump and restore it when needed

# Stop all other containers so the db is not changed while you export it
docker compose stop web nginx cache celery_worker celery_beat
docker compose exec db pg_dumpall --clean --username wger > backup.sql
docker compose start

# When you need to restore it
docker compose stop
docker volume remove docker_postgres-data
docker compose up db
cat backup.sql | docker compose exec -T db psql --username wger --dbname wger
docker compose up

Media volume: If you haven't uploaded any own images (exercises, gallery), you don't need to backup this, the contents can just be downloaded again. If you have, please consult these possibilities:

Static volume: The contents of this volume are 100% generated and recreated on startup, no need to backup anything

Postgres Upgrade

It is sadly not possible to automatically upgrade between postgres versions, you need to perform the upgrade manually. Since the amount of data the app generates is small a simple dump and restore is the simplest way to do this.

If you pulled new changes from this repo and got the error message "The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15." this is for you.

See also docker-library/postgres#37

# Checkout the last version of the composer file that uses postgres 12 
git checkout pg-12

# Stop all other containers
docker compose stop web nginx cache celery_worker celery_beat

# Make a dump of the database and remove the container and volume
docker compose exec db pg_dumpall --clean --username wger > backup.sql
docker compose stop db
docker compose down
docker volume remove docker_postgres-data

# Checkout current version, import the dump and start everything
git checkout master
docker compose up db
cat backup.sql | docker compose exec -T db psql --username wger --dbname wger
docker compose exec -T db psql --username wger --dbname wger -c "ALTER USER wger WITH PASSWORD 'wger'"
docker compose up
rm backup.sql

Building

If you want to build the images yourself, clone the wger repository and follow the instructions for the devel image in the extras/docker folder.

Contact

Feel free to contact us if you found this useful or if there was something that didn't behave as you expected. We can't fix what we don't know about, so please report liberally. If you're not sure if something is a bug or not, feel free to file a bug anyway.

Sources

All the code and the content is freely available:

Licence

The application is licenced under the Affero GNU General Public License 3 or later (AGPL 3+).

docker's People

Contributors

alexashs avatar comradekingu avatar goodnewz avatar kuseler avatar mohammadrafigh avatar rolandgeider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docker's Issues

Almost there... so close - Problems launching

I'm almost there! I am having a few issues, and I haven't been able to figure out what to do about this. This is what I get when I try to open the port on my browser

Environment:


Request Method: GET
Request URL: http://192.168.1.9/en/software/features

Django Version: 3.1.5
Python Version: 3.8.5
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'django_extensions',
 'storages',
 'wger.config',
 'wger.core',
 'wger.mailer',
 'wger.exercises',
 'wger.gym',
 'wger.manager',
 'wger.nutrition',
 'wger.software',
 'wger.utils',
 'wger.weight',
 'captcha',
 'django.contrib.sitemaps',
 'easy_thumbnails',
 'compressor',
 'crispy_forms',
 'rest_framework',
 'rest_framework.authtoken',
 'django_filters',
 'django_bootstrap_breadcrumbs',
 'corsheaders')
Installed Middleware:
('corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'wger.utils.middleware.JavascriptAJAXRedirectionMiddleware',
 'wger.utils.middleware.WgerAuthenticationMiddleware',
 'wger.utils.middleware.RobotsExclusionMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.locale.LocaleMiddleware')



Traceback (most recent call last):
  File "/home/wger/src/wger/utils/language.py", line 55, in load_language
    language = Language.objects.get(short_name=used_language)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 429, in get
    raise self.model.DoesNotExist(

During handling of the above exception (Language matching query does not exist.), another exception occurred:
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/wger/src/wger/software/views.py", line 35, in features
    return render(request, 'features.html', context)
  File "/usr/local/lib/python3.8/dist-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/usr/local/lib/python3.8/dist-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/usr/local/lib/python3.8/dist-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 168, in render
    with context.bind_template(self):
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.8/dist-packages/django/template/context.py", line 244, in bind_template
    updates.update(processor(self.request))
  File "/home/wger/src/wger/utils/context_processor.py", line 29, in processor
    language = load_language()
  File "/home/wger/src/wger/utils/language.py", line 58, in load_language
    language = Language.objects.get(short_name="en")
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 429, in get
    raise self.model.DoesNotExist(

Exception Type: DoesNotExist at /en/software/features
Exception Value: Language matching query does not exist.

Likewise, this is the error on the *-web container

Waiting for postgres...,
PostgreSQL started :),
yarn install v1.22.5
,
[1/5] Validating package.json...
,
[2/5] Resolving packages...
,
[3/5] Fetching packages...
,
[4/5] Linking dependencies...
,
warning " > [email protected]" has unmet peer dependency "popper.js@^1.16.1".
,
[5/5] Building fresh packages...
,
Done in 20.74s.
,
yarn run v1.22.5
,
$ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
,
Done in 7.45s.
,
Running in production mode, running collectstatic now,
,
4514 static files copied to '/home/wger/static', 279 unmodified.,
Using gunicorn...,
[2021-01-14 04:45:34 +0000] [59] [INFO] Starting gunicorn 20.0.4,
[2021-01-14 04:45:34 +0000] [59] [INFO] Listening at: http://0.0.0.0:8000 (59),
[2021-01-14 04:45:34 +0000] [59] [INFO] Using worker: sync,
[2021-01-14 04:45:35 +0000] [61] [INFO] Booting worker with pid: 61,
Internal Server Error: /en/software/features,
Traceback (most recent call last):,
  File "/home/wger/src/wger/utils/language.py", line 55, in load_language,
    language = Language.objects.get(short_name=used_language),
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/manager.py", line 85, in manager_method,
    return getattr(self.get_queryset(), name)(*args, **kwargs),
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 429, in get,
    raise self.model.DoesNotExist(,
wger.core.models.Language.DoesNotExist: Language matching query does not exist.,
,
During handling of the above exception, another exception occurred:,
,
Traceback (most recent call last):,
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner,
    response = get_response(request),
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response,
    response = wrapped_callback(request, *callback_args, **callback_kwargs),
  File "/home/wger/src/wger/software/views.py", line 35, in features,
    return render(request, 'features.html', context),
  File "/usr/local/lib/python3.8/dist-packages/django/shortcuts.py", line 19, in render,
    content = loader.render_to_string(template_name, context, request, using=using),
  File "/usr/local/lib/python3.8/dist-packages/django/template/loader.py", line 62, in render_to_string,
    return template.render(context, request),
  File "/usr/local/lib/python3.8/dist-packages/django/template/backends/django.py", line 61, in render,
    return self.template.render(context),
  File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 168, in render,
    with context.bind_template(self):,
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__,
    return next(self.gen),
  File "/usr/local/lib/python3.8/dist-packages/django/template/context.py", line 244, in bind_template,
    updates.update(processor(self.request)),
  File "/home/wger/src/wger/utils/context_processor.py", line 29, in processor,
    language = load_language(),
  File "/home/wger/src/wger/utils/language.py", line 58, in load_language,
    language = Language.objects.get(short_name="en"),
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/manager.py", line 85, in manager_method,
    return getattr(self.get_queryset(), name)(*args, **kwargs),
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 429, in get,
    raise self.model.DoesNotExist(,
wger.core.models.Language.DoesNotExist: Language matching query does not exist.,

Do you understand what is wrong with this and how I can make it work?
Thank you very much!

Requires latest Ubuntu version?

Attempting to install via the docker-compose file, I get a bunch of errors regarding GPG keys for Ubuntu Jammy where the server is currently running 16.04 (I know, it's not new).

Does wger require the latest Ubuntu version?

If so, would be good to have this made clear within the installation documentation. I can do that if confirmed.

~/wger/extras/docker [master ?] /: docker build base/
Sending build context to Docker daemon  4.608kB

Step 1/10 : FROM ubuntu:22.04

 ---> 08d22c0ceb15
Step 2/10 : LABEL maintainer="Roland Geider <[email protected]>"
 ---> Running in 1e495de2704b
Removing intermediate container 1e495de2704b
 ---> 94f1a80434c8
Step 3/10 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Running in d2ff60bd3294
Removing intermediate container d2ff60bd3294
 ---> 63ae26f68f0e
Step 4/10 : RUN apt-get update   && apt-get install --no-install-recommends -y       git       locales       nodejs       npm       python3-venv       python3-pip       sqlite3       wget       libpq5   && rm -rf /var/lib/apt/lists/*   && npm install -g yarn sass  && locale-gen en_US.UTF-8
 ---> Running in 8851dbd3500d
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Err:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Err:2 http://archive.ubuntu.com/ubuntu jammy InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [108 kB]
Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
Reading package lists...
W: http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://security.ubuntu.com/ubuntu jammy-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://security.ubuntu.com/ubuntu jammy-security InRelease' is not signed.
W: http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://archive.ubuntu.com/ubuntu jammy InRelease' is not signed.
W: http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-updates InRelease' is not signed.
W: http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-backports InRelease' is not signed.
E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'
E: Sub-process returned an error code
The command '/bin/sh -c apt-get update   && apt-get install --no-install-recommends -y       git       locales       nodejs       npm       python3-venv       python3-pip       sqlite3       wget       libpq5   && rm -rf /var/lib/apt/lists/*   && npm install -g yarn sass  && locale-gen en_US.UTF-8' returned a non-zero code: 100

Something happened that caused an error

Hi there,

After updating the image to the latest verssion of wger server and redis, now I'm unable to access the application. A message saying : " An error occurred Something happened that caused an error." appear on screen. I've checked the log but there is nothing I put it in here anyway.

###Redis

1:C 23 Apr 2022 06:45:08.013 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 23 Apr 2022 06:45:08.013 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 23 Apr 2022 06:45:08.014 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 23 Apr 2022 06:45:08.016 * monotonic clock: POSIX clock_gettime
1:M 23 Apr 2022 06:45:08.020 * Running mode=standalone, port=6379.
1:M 23 Apr 2022 06:45:08.024 # Server initialized
1:M 23 Apr 2022 06:45:08.024 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 23 Apr 2022 06:45:08.031 * Loading RDB produced by version 6.2.6
1:M 23 Apr 2022 06:45:08.031 * RDB age 12 seconds
1:M 23 Apr 2022 06:45:08.031 * RDB memory usage when created 0.83 Mb
1:M 23 Apr 2022 06:45:08.032 # Done loading RDB, keys loaded: 82, keys expired: 0.
1:M 23 Apr 2022 06:45:08.032 * DB loaded from disk: 0.001 seconds
1:M 23 Apr 2022 06:45:08.032 * Ready to accept connections

####Server

Waiting for postgres...
PostgreSQL started :)
yarn install v1.22.18
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
Done in 71.81s.
yarn run v1.22.18
$ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
Done in 10.00s.
Running in production mode, running collectstatic now

5723 static files copied to '/home/wger/static', 295 unmodified.
Using gunicorn...
[2022-04-23 06:37:47 +0000] [58] [INFO] Starting gunicorn 20.1.0
[2022-04-23 06:37:47 +0000] [58] [INFO] Listening at: http://0.0.0.0:8000 (58)
[2022-04-23 06:37:47 +0000] [58] [INFO] Using worker: sync
[2022-04-23 06:37:50 +0000] [59] [INFO] Booting worker with pid: 59
Waiting for postgres...
PostgreSQL started :)
yarn install v1.22.18
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.75s.
yarn run v1.22.18
$ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
Done in 9.37s.
Running in production mode, running collectstatic now

2 static files copied to '/home/wger/static', 6016 unmodified.
Using gunicorn...
[2022-04-23 06:45:30 +0000] [50] [INFO] Starting gunicorn 20.1.0
[2022-04-23 06:45:30 +0000] [50] [INFO] Listening at: http://0.0.0.0:8000 (50)
[2022-04-23 06:45:30 +0000] [50] [INFO] Using worker: sync
[2022-04-23 06:45:30 +0000] [51] [INFO] Booting worker with pid: 51

######DB

PostgreSQL Database directory appears to contain a database; Skipping initialization

2022-04-23 06:45:08.305 UTC [1] LOG:  starting PostgreSQL 12.10 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027, 64-bit
2022-04-23 06:45:08.305 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2022-04-23 06:45:08.305 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2022-04-23 06:45:08.428 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-04-23 06:45:08.689 UTC [22] LOG:  database system was shut down at 2022-04-23 06:44:56 UTC
2022-04-23 06:45:08.737 UTC [1] LOG:  database system is ready to accept connections

Thanks for any help.

Confused with which image I should be using

The main repo says:

If you want to host your own instance, take a look at the provided docker compose file. This config will persist your database and uploaded images

But then the docker compose file uses wger/devel, which in its description says:

Please note that this image is intended for development

And then says to check out the docker compose file instead.

The other images (wger/apache and wger/base) are both also apparently not intended for production usage. So what am I meant to do if I want to deploy a production instance of wger via docker?

Think about automating the upgrade process

At the moment some changes from upstream require manual steps like database migrations. On one hand it would be nice if this would happen during startup, on the other hand... they are db migrations that could potentially make the user lose all their data.

Docker compose without ngix (local/LAN use only)?

Hi,

Please could someone help me with what the Docker compose needs to be for a local/lan only (no ngix) set up?

I’ve tried what i can, and have got the following, so far, which is not quite working as expected ...

version: '3'
services:
  web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      db:
        condition: service_healthy
      cache:
        condition: service_healthy
    environment: 
      - SECRET_KEY=wger-docker-supersecret-key
      - SIGNING_KEY=wger-docker-secret-jwtkey
      - [email protected]
      - TIME_ZONE=Europe/London
      - ALLOW_REGISTRATION=True
      - ALLOW_GUEST_USERS=True
      - ALLOW_UPLOAD_VIDEOS=True
      - MIN_ACCOUNT_AGE_TO_TRUST=18
      - SYNC_EXERCISES_ON_STARTUP=True
      - DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=True
      # Database
      - DJANGO_DB_ENGINE=django.db.backends.postgresql
      - DJANGO_DB_DATABASE=wger
      - DJANGO_DB_USER=wger
      - DJANGO_DB_PASSWORD=wger
      - DJANGO_DB_HOST=db
      - DJANGO_DB_PORT=5432
      - DJANGO_PERFORM_MIGRATIONS=True
      # Cache
      - DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
      - DJANGO_CACHE_LOCATION=redis://cache:6379/1
      # 60*60*24*15, 15 Days
      - DJANGO_CACHE_TIMEOUT=12
      - DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient
      # Brute force login attacks - https://django-axes.readthedocs.io/en/latest/index.html
      - AXES_ENABLED=True
      - AXES_FAILURE_LIMIT=10
      # in minutes
      - AXES_COOLOFF_TIME=30
      - AXES_HANDLER=axes.handlers.cache.AxesCacheHandler
      # Others
      - DJANGO_DEBUG=False
      - WGER_USE_GUNICORN=True
      - EXERCISE_CACHE_TTL=10
      - SITE_URL=http://localhost
      # JWT auth - The lifetime duration of the access token, in minutes
      - ACCESS_TOKEN_LIFETIME=10
      # The lifetime duration of the refresh token, in hours
      - REFRESH_TOKEN_LIFETIME=24
      # Other possible settings
      # RECAPTCHA_PUBLIC_KEY
      # RECAPTCHA_PRIVATE_KEY
      # NOCAPTCHA
      # https://docs.djangoproject.com/en/4.1/topics/email/#smtp-backend
      # ENABLE_EMAIL
      # EMAIL_HOST
      # EMAIL_PORT
      # EMAIL_HOST_USER
      # EMAIL_HOST_PASSWORD
      # EMAIL_USE_TLS
      # EMAIL_USE_SSL
      # DJANGO_MEDIA_ROOT
      # DJANGO_STATIC_ROOT
    volumes:
      - /share/Container/wger/static:/home/wger/static
      - /share/Container/wger/media:/home/wger/media
    ports:
      - "8000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  db:
    image: postgres:12-alpine
    container_name: wger_db
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=wger
      - POSTGRES_DB=wger
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  cache:
    image: redis
    container_name: wger_cache
    expose:
      - 6379
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres-data:
  static:
  media:

networks:
  default:
      name: wger_network

I can access Wger and register but the ui is very basic? See below.. (any ideas)?

Docker: Error downloading exercise-images

When I try to update the exercise-images of the docker I obtain this error:

lordpedal@overclock:~/docker/wger$ docker-compose exec web python3 manage.py download-exercise-images

*** Processing 2 Handed Kettlebell Swing (ID: 345, UUID: c788d643-150a-4ac7-97ef-84643c6419bf)
    No images for this exercise, nothing to do

*** Processing Abduktoren-Maschine (ID: 174, UUID: 99881bdd-43d7-4c3b-82ed-9c187d0455b7)
    No images for this exercise, nothing to do

*** Processing Adduktoren Maschine (ID: 223, UUID: e56d0a17-b1b8-427d-991e-97c530c7db6a)
    No images for this exercise, nothing to do

*** Processing Arnold Press (ID: 228, UUID: 880bff63-6798-4ffc-a818-b2a1ccfec0f7)
    Fetching image 193 - Arnold-press-2.png
    --> Image not found in local DB, creating now...
Traceback (most recent call last):
  File "manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/dist-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/home/wger/src/wger/exercises/management/commands/download-exercise-images.py", line 137, in handle
    image.exercise = exercise
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/fields/related_descriptors.py", line 215, in __set__
    raise ValueError(
ValueError: Cannot assign "<Exercise: Arnold Press>": "ExerciseImage.exercise" must be a "ExerciseBase" instance.

Meanwhile the other command work fine, without fails:

lordpedal@overclock:~/docker/wger$ docker-compose exec web wger load-online-fixtures
*** No settings given, using /home/wger/src/settings.py
Downloading fixture data from https://github.com/wger-project/data/raw/master/fixtures/ingredients.json.zip...
-> fixture size: 5.03 MB
-> saving to temp file /tmp/tmph_fl0esl.json.zip
Installed 78854 object(s) from 1 fixture(s)
-> removing temp file

Downloading fixture data from https://github.com/wger-project/data/raw/master/fixtures/weight_units.json.zip...
-> fixture size: 0.0201 MB
-> saving to temp file /tmp/tmpc7zfenk3.json.zip
Installed 1897 object(s) from 1 fixture(s)
-> removing temp file

Downloading fixture data from https://github.com/wger-project/data/raw/master/fixtures/ingredient_units.json.zip...
-> fixture size: 0.13 MB
-> saving to temp file /tmp/tmp1nwmvv97.json.zip
Installed 14274 object(s) from 1 fixture(s)
-> removing temp file

Best regards

Exercises Not syncing

After running.

docker-compose exec web python3 manage.py sync-exercises

*** Synchronizing categories...
done!

*** Synchronizing muscles...
done!

*** Synchronizing equipment...
done!

*** Synchronizing exercises...
Saved new exercise 2 Handed Kettlebell Swing
Traceback (most recent call last):
File "/home/wger/src/wger/exercises/management/commands/sync-exercises.py", line 104, in sync_exercises
exercise = Exercise.objects.get(uuid=exercise_uuid)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 435, in get
raise self.model.DoesNotExist(
wger.exercises.models.exercise.Exercise.DoesNotExist: Exercise matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.ForeignKeyViolation: insert or update on table "exercises_exercisebase" violates foreign key constraint "exercises_exercisebase_license_id_7d658f59_fk_core_license_id"
DETAIL: Key (license_id)=(2) is not present in table "core_license".

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/wger/src/manage.py", line 25, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/init.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.10/dist-packages/django/core/management/init.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/home/wger/src/wger/exercises/management/commands/sync-exercises.py", line 84, in handle
self.sync_exercises(headers, remote_url)
File "/home/wger/src/wger/exercises/management/commands/sync-exercises.py", line 125, in sync_exercises
base.save()
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 739, in save
self.save_base(using=using, force_insert=force_insert,
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 776, in save_base
updated = self._save_table(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 881, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 919, in _do_insert
return manager._insert(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 1270, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 79, in _execute
with self.db.wrap_database_errors:
File "/usr/local/lib/python3.10/dist-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: insert or update on table "exercises_exercisebase" violates foreign key constraint "exercises_exercisebase_license_id_7d658f59_fk_core_license_id"
DETAIL: Key (license_id)=(2) is not present in table "core_license".

Can't start production wger docker

I was able to get wger/apache up and running since it has a very straightforward docker-compose. However, it doesn't save data and everything is wiped on container restart.

How do I get the production-ish version up and running if I already have a separate Nginx Proxy Manager for my LAN-only network? Even before setting up a wger reverse proxy, I still can't access via http://PORT:IP.

docker-compose.yaml
version: '3.7'

services:
  web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      db:
        condition: service_healthy
      cache:
        condition: service_healthy
    env_file:
      - ./config/prod.env
    volumes:
      - static:/home/wger/static
      - media:/home/wger/media
      # For development, mount your local git checkout
      # - type: bind
      #  source: /path/to/wger/sourcecode
      #  target: /home/wger/src/
    ports:
      - "8004:8000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

#  nginx:
#    image: nginx:stable
#    container_name: wger_nginx
#    depends_on:
#      - web
#    volumes:
#      - ./config/nginx.conf:/etc/nginx/conf.d/default.conf
#      - static:/wger/static:ro
#      - media:/wger/media:ro
#    ports:
#      - "80:80"
#    healthcheck:
#      test: service nginx status
#      interval: 10s
#      timeout: 5s
#      retries: 5
#    restart: unless-stopped

  db:
    image: postgres:12-alpine
    container_name: wger_db
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=wger
      - POSTGRES_DB=wger
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  cache:
    image: redis
    container_name: wger_cache
    expose:
      - 6379
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres-data:
  static:
  media:

networks:
  default:
    name: nginx_proxy

Above is s the docker-compose I modified by removing the nginx section and changing the web port to 8004:8000. Starting wger this way results in "An error occurred. Something happened that caused an error." If I set DJANGO_DEBUG=True, I see the following:

connection to server at "db" (172.16.64.15), port 5432 failed: FATAL:  password authentication failed for user "wger"

prod.env and my docker-compose both retain default settings for user, password, and db, so I'm not sure why I'm getting this error. What else can I do to troubleshoot?

Managing settings.py

While the DB can be set via environmental variables, currently there is no way to edit the other things in settings.py without getting overwritten with a new image pull

webgui images "Not Found"

Hi, I have had wger working in a previous docker install, but I am having trouble re-instating it in a new VM.

Container seems to start fine.
image

Then when I open the webui, non of the images are displayed and I get these errors in the logs.
image

image

Checking the volumes and the images are there.
image

My docker compose:

version: '3.7'

services:
  web:
    restart: always
    image: wger/server:latest
    volumes:
      - /var/lib/docker/volumes/wger_static:/home/wger/static:rw
      - /var/lib/docker/volumes/wger_media:/home/wger/media:rw
    ports:
      - 8084:8000
#    env_file:
#      - ./.prod.env # cannot figure out how to get .env files to be pulled by portainer
    environment:
      - DJANGO_DB_ENGINE=django.db.backends.postgresql
      - DJANGO_DB_DATABASE=wger
      - DJANGO_DB_USER=wger
      - DJANGO_DB_PASSWORD=wger
      - DJANGO_DB_HOST=db
      - DJANGO_DB_PORT=5432
      - DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
      - DJANGO_CACHE_LOCATION=redis://cache:6379/1
      - DJANGO_CACHE_TIMEOUT=1296000 # 60*60*24*15, 15 Days
      - DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient
      - DJANGO_MEDIA_ROOT=/home/wger/media
      - SECRET_KEY= wger-docker-secret-key # Change the secret key to a random string if you are running this instance publicly
      - ALLOW_REGISTRATION=True
      - ALLOW_GUEST_USERS=False
      - [email protected]  # The 'from' address used when sending emails
      - DJANGO_DEBUG=False
      - WGER_USE_GUNICORN=True
      - TIME_ZONE=UTZ
      - SITE_URL=http://localhost:8084
      - ENABLE_EMAIL=True
      - EMAIL_HOST=smtp.gmail.com
      - EMAIL_PORT=465
      - [email protected]
      - EMAIL_HOST_PASSWORD=password
      - EMAIL_USE_TLS=False
      - EMAIL_USE_SSL=True
    depends_on:
      - db
      - cache

#  nginx:
#    build: ./nginx
#    volumes:
#      - static:/wger/static:ro
#      - media:/wger/media:ro
#    ports:
#      - 80:80
#    depends_on:
#      - web

  db:
    restart: always
    image: postgres:12-alpine
    volumes:
      - /var/lib/docker/volumes/wger_postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=wger
      - POSTGRES_DB=wger

  cache:
    restart: always
    image: redis:latest
    volumes:
      - /var/lib/docker/volumes/wger_redis-data:/data
    expose:
      - 6379

Any help would be appreciated :)

No exercises show up

I recently installed the wger docker-compose image. After running it and running the optional download of exercises

docker-compose exec web python3 manage.py sync-exercises
docker-compose exec web python3 manage.py download-exercise-images
docker-compose exec web wger load-online-fixtures

I logged in and tried to add an exercise. When on the "new set" page, I search for a common exercise (bench press, for instance), and first it says No items found! but shortly after it says in red Error: Instance of 'NoSuchEntryException'.
I can't add exercises if they are not on the list, even if I write down the exercise name, below the search box a text appears that says Please select an exercise.

What seems to be the problem? I have repeatedly run the commands above to sync the exercises, but that won't solve the issue.

WGER does not display correctly

Good day

I do not know if this issue has been raised, and I do not know how to search for it. I am running wger in docker, but all of a sudden it looks like the attached photo. Please help. I can't seem to fix it. It looks like it doesn't see or load the CSS on the page, but I'm not sure. It happens in all browsers, so it's not a plugin causing it.

image

Thank you
Darius

importlib.metadata.PackageNotFoundError: wger

Hello,

I can't get your example working, I get the following error in the web docker-compose logs:

web_1         | Waiting for postgres...
web_1         | PostgreSQL started :)
web_1         | Traceback (most recent call last):
web_1         |   File "/usr/bin/wger", line 33, in <module>
web_1         |     sys.exit(load_entry_point('wger', 'console_scripts', 'wger')())
web_1         |   File "/usr/bin/wger", line 22, in importlib_load_entry_point
web_1         |     for entry_point in distribution(dist_name).entry_points
web_1         |   File "/usr/lib/python3.9/importlib/metadata.py", line 524, in distribution
web_1         |     return Distribution.from_name(distribution_name)
web_1         |   File "/usr/lib/python3.9/importlib/metadata.py", line 187, in from_name
web_1         |     raise PackageNotFoundError(name)
web_1         | importlib.metadata.PackageNotFoundError: wger
web_1         | Running in production mode, running collectstatic now

Thanks for looking into this, sorry that I don't have anything else to add.

Video 413 Request Entity Too Large

Steps to Reproduce

  1. activate Videoupload in wger Docker
  2. Try upload a video
  3. get 413

Expected results:
working videoupload

Actual results:
Limited file size by nginx setting

Needs some additional command in nginx wger folder for higher bodysize limit

wger-project/wger#1014

Wgner do not load CSS and exercises at all

When I load home page there is no CSS or pictures at all.

Console:

GET http://192.168.1.248:8005/static/CACHE/css/output.bb29faf5c6cc.css net::ERR_ABORTED 404 (Not Found)
features:55 GET http://192.168.1.248:8005/static/CACHE/js/output.47a47acd93ca.js net::ERR_ABORTED 404 (Not Found)
features:329 GET http://192.168.1.248:8005/static/yarn/shariff/dist/shariff.min.js net::ERR_ABORTED 404 (Not Found)
features:158 GET http://192.168.1.248:8005/static/images/weight-chart.png 404 (Not Found)
features:173 GET http://192.168.1.248:8005/static/images/calendar.png 404 (Not Found)
features:218 GET http://192.168.1.248:8005/static/images/rest-api.png 404 (Not Found)
features:203 GET http://192.168.1.248:8005/static/images/gym-management.png 404 (Not Found)
features:188 GET http://192.168.1.248:8005/static/images/muscle-overview.png 404 (Not Found)
favicon.png:1 GET http://192.168.1.248:8005/static/images/favicon.png 404 (Not Found)

Please help

Password Reset E-Mail ignores SITE_URL in .env

Steps to Reproduce

  1. Setup Wger docker
  2. Set SITE_URL in .env
  3. request a password forgotten email
  4. see the link with example.com

Expected results:
actual site url in email

Actual results:

Diese E-Mail wurde aufgrund einer Anfrage zum Zurücksetzen des Passworts auf der Website [example.com](http://example.com/) versendet.

Bitte öffne folgende Seite, um dein neues Passwort einzugeben:

http://example.com/de/user/password/reset/check/MQ/b326v2-db29a74f3682933d0e88afca6ded9e32


Dein Benutzername, falls du ihn vergessen hast: admin

Vielen Dank, dass du unsere Website benutzt!

Das Team von [example.com](http://example.com/)

Newb-tube question

First time using docker to install a program sequence such as this one. I may need a little hand-holding or the right repo to follow instructions from. Anyone have the 411 on that?

Error parsing template

Hi everyone, I keep getting this error whenever I launch the server. I experience a few problems related to translation and users management as an admin, but besides from that, no problem with syncing with the Android App.

image

Error whe adding an image to an exercise

When I try to add an image to an exercise I got the error Key (id)=(4) already exists. If I keep trying the number will be increasing and sometimes it will eventually work. It happen after a fresh install from version 2.0-dev using docker-compose (as described in https://github.com/wger-project/docker). If I try to do it on another exercise the problem is the same and the key (id) keeps increasing by one at time. Can I change key ID by an Unix timestamp?

The error log is:

(Request Method: | POST
-- | --
http://10.0.0.10/pt/exercise/image/160/image/add
3.1.7
IntegrityError
duplicate key value violates unique constraint "exercises_exerciseimage_pkey" DETAIL:  Key (id)=(4) already exists.
/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py, line 84, in _execute
/usr/bin/python3
3.8.5
['/usr/local/bin',  '/usr/lib/python38.zip',  '/usr/lib/python3.8',  '/usr/lib/python3.8/lib-dynload',  '/usr/local/lib/python3.8/dist-packages',  '/home/wger/src',  '/usr/lib/python3/dist-packages']
Thu, 25 Mar 2021 16:32:54 +0100)

Environment:

Request Method: POST
Request URL: http://10.0.0.10/pt/exercise/image/160/image/add

Django Version: 3.1.7
Python Version: 3.8.5
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'django_extensions',
 'storages',
 'wger.config',
 'wger.core',
 'wger.mailer',
 'wger.exercises',
 'wger.gym',
 'wger.manager',
 'wger.nutrition',
 'wger.software',
 'wger.utils',
 'wger.weight',
 'captcha',
 'django.contrib.sitemaps',
 'easy_thumbnails',
 'compressor',
 'crispy_forms',
 'rest_framework',
 'rest_framework.authtoken',
 'django_filters',
 'django_bootstrap_breadcrumbs',
 'corsheaders')
Installed Middleware:
('corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'wger.utils.middleware.JavascriptAJAXRedirectionMiddleware',
 'wger.utils.middleware.WgerAuthenticationMiddleware',
 'wger.utils.middleware.RobotsExclusionMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.locale.LocaleMiddleware')



Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)

The above exception (duplicate key value violates unique constraint "exercises_exerciseimage_pkey"
DETAIL:  Key (id)=(4) already exists.
) was the direct cause of the following exception:
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/wger/src/wger/utils/generic_views.py", line 199, in dispatch
    return super(WgerFormMixin, self).dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/mixins.py", line 52, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/mixins.py", line 85, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/views/generic/edit.py", line 172, in post
    return super().post(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/views/generic/edit.py", line 142, in post
    return self.form_valid(form)
  File "/home/wger/src/wger/exercises/views/images.py", line 99, in form_valid
    return super(ExerciseImageAddView, self).form_valid(form)
  File "/home/wger/src/wger/utils/generic_views.py", line 246, in form_valid
    return super(WgerFormMixin, self).form_valid(form)
  File "/usr/local/lib/python3.8/dist-packages/django/views/generic/edit.py", line 125, in form_valid
    self.object = form.save()
  File "/usr/local/lib/python3.8/dist-packages/django/forms/models.py", line 460, in save
    self.instance.save()
  File "/home/wger/src/wger/exercises/models.py", line 502, in save
    super(ExerciseImage, self).save(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/base.py", line 753, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/base.py", line 790, in save_base
    updated = self._save_table(
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/base.py", line 895, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/base.py", line 933, in _do_insert
    return manager._insert(
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/query.py", line 1254, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py", line 1397, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/dist-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.8/dist-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)

Exception Type: IntegrityError at /pt/exercise/image/160/image/add
Exception Value: duplicate key value violates unique constraint "exercises_exerciseimage_pkey"
DETAIL:  Key (id)=(4) already exists.

[Feature Request] All-In-One Docker Image

As the main purpose of docker containers is the quick, easy, and scalable deployment of software, having to manage multiple of them for a single app can be tedious when one plans to host multiple wger instances.

Additionally I suspect some of the problems that arise in the docker in regards to data persistence, volumes, and binding local directories can be traced back to permissions errors between the different containers. A singular container allows for tighter controls of these and properly setup with environment variables like "GID" and "UID" would allow for rootless operation, which is an important feature to have.

Finally it would allow for the cleanup of environment variables, as some might not be needed anymore and simplify the nginx setup.

I know this is a tall order and probably a good bit of work, but it would make for much easier deployment, more consistency, and likely fix some errors reported here along the way.

email error

wger | Traceback (most recent call last):
wger | File "/usr/local/lib/python3.10/dist-packages/environ/environ.py", line 403, in get_value
wger | value = self.ENVIRON[var_name]
wger | File "/usr/lib/python3.10/os.py", line 679, in getitem
wger | raise KeyError(key) from None
wger | KeyError: 'FROM_EMAIL'
wger |
wger | The above exception was the direct cause of the following exception:
wger |
wger | Traceback (most recent call last):
wger | File "/usr/local/bin/invoke", line 8, in
wger | sys.exit(program.run())
wger | File "/usr/local/lib/python3.10/dist-packages/invoke/program.py", line 384, in run
wger | self.execute()
wger | File "/usr/local/lib/python3.10/dist-packages/invoke/program.py", line 569, in execute
wger | executor.execute(*self.tasks)
wger | File "/usr/local/lib/python3.10/dist-packages/invoke/executor.py", line 129, in execute
wger | result = call.task(*args, **call.kwargs)
wger | File "/usr/local/lib/python3.10/dist-packages/invoke/tasks.py", line 127, in call
wger | result = self.body(*args, **kwargs)
wger | File "/home/wger/src/wger/tasks.py", line 91, in bootstrap
wger | setup_django_environment(settings_path)
wger | File "/home/wger/src/wger/tasks.py", line 345, in setup_django_environment
wger | django.setup()
wger | File "/usr/local/lib/python3.10/dist-packages/django/init.py", line 19, in setup
wger | configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
wger | File "/usr/local/lib/python3.10/dist-packages/django/conf/init.py", line 82, in getattr
wger | self._setup(name)
wger | File "/usr/local/lib/python3.10/dist-packages/django/conf/init.py", line 69, in _setup
wger | self._wrapped = Settings(settings_module)
wger | File "/usr/local/lib/python3.10/dist-packages/django/conf/init.py", line 170, in init
wger | mod = importlib.import_module(self.SETTINGS_MODULE)
wger | File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
wger | return _bootstrap._gcd_import(name[level:], package, level)
wger | File "", line 1050, in _gcd_import
wger | File "", line 1027, in _find_and_load
wger | File "", line 1006, in _find_and_load_unlocked
wger | File "", line 688, in _load_unlocked
wger | File "", line 883, in exec_module
wger | File "", line 241, in _call_with_frames_removed
wger | File "/home/wger/src/settings.py", line 90, in
wger | WGER_SETTINGS['EMAIL_FROM'] = f'wger Workout Manager <{env.str("FROM_EMAIL")}>'
wger | File "/usr/local/lib/python3.10/dist-packages/environ/environ.py", line 213, in str
wger | value = self.get_value(var, cast=str, default=default)
wger | File "/usr/local/lib/python3.10/dist-packages/environ/environ.py", line 407, in get_value
wger | raise ImproperlyConfigured(error_msg) from exc
wger | django.core.exceptions.ImproperlyConfigured: Set the FROM_EMAIL environment variable

Cant get Wger to work properly ? Is it my configuration ? , permissions? … :(

Hi,

no matter what I try, I can’t seem to get the Wger Docker instance to work correctly.. I’ve created 3 persistent local locations to store config, media and static content , but they don’t seem to get picked up. If someone is able to review / or better yet try my config (or a close approximation of it,) that would help me a lot..

my Docker compose is..

version: '3'
services:
  web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      db:
        condition: service_healthy
      cache: 
        condition: service_healthy
    environment: 
      - SECRET_KEY=wger-docker-supersecret-key
      - SIGNING_KEY=wger-docker-secret-jwtkey
      - [email protected]
      - TIME_ZONE=Europe/London
      - ALLOW_REGISTRATION=True
      - ALLOW_GUEST_USERS=True
      - ALLOW_UPLOAD_VIDEOS=True
      - MIN_ACCOUNT_AGE_TO_TRUST=18
      - SYNC_EXERCISES_ON_STARTUP=True
      - DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=True
      # Database
      - DJANGO_DB_ENGINE=django.db.backends.postgresql
      - DJANGO_DB_DATABASE=wger
      - DJANGO_DB_USER=wger
      - DJANGO_DB_PASSWORD=wger
      - DJANGO_DB_HOST=db
      - DJANGO_DB_PORT=5432
      - DJANGO_PERFORM_MIGRATIONS=True
      # Cache
      - DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
      - DJANGO_CACHE_LOCATION=redis://cache:6379/1
      # 60*60*24*15, 15 Days
      - DJANGO_CACHE_TIMEOUT=12
      - DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient
      # Brute force login attacks - https://django-axes.readthedocs.io/en/latest/index.html
      - AXES_ENABLED=True
      - AXES_FAILURE_LIMIT=10
      # in minutes
      - AXES_COOLOFF_TIME=30
      - AXES_HANDLER=axes.handlers.cache.AxesCacheHandler
      # Others
      - DJANGO_DEBUG=True
      - WGER_USE_GUNICORN=True
      - EXERCISE_CACHE_TTL=10
      # SITE_URL=http://localhost
      # JWT auth - The lifetime duration of the access token, in minutes
      - ACCESS_TOKEN_LIFETIME=10
      # The lifetime duration of the refresh token, in hours
      - REFRESH_TOKEN_LIFETIME=24
      # Other possible settings
      # RECAPTCHA_PUBLIC_KEY
      # RECAPTCHA_PRIVATE_KEY
      # NOCAPTCHA
      # https://docs.djangoproject.com/en/4.1/topics/email/#smtp-backend
      # ENABLE_EMAIL
      # EMAIL_HOST
      # EMAIL_PORT
      # EMAIL_HOST_USER
      # EMAIL_HOST_PASSWORD
      # EMAIL_USE_TLS
      # EMAIL_USE_SSL
      # DJANGO_MEDIA_ROOT
      # DJANGO_STATIC_ROOT
      - CSRF_TRUSTED_ORIGINS=https://192.168.102.134,http://192.168.102.134
    volumes:
      - /share/Container/wger/static:/home/wger/static
      - /share/Container/wger/media:/home/wger/media
    ports:
      - "8000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  nginx:
    image: nginx:stable
    container_name: wger_nginx
    depends_on:
      - web
    volumes:
      #- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
      - /share/Container/wger/config/nginx.conf:/etc/nginx/conf.d/default.conf
      - /share/Container/wger/static:/wger/static:ro
      - /share/Container/wger/media:/wger/media:ro
    ports:
      - "8008:80"
    healthcheck:
      test: service nginx status
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  db:
    image: postgres:12-alpine
    container_name: wger_db
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=wger
      - POSTGRES_DB=wger
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  cache:
    image: redis
    container_name: wger_cache
    expose:
      - 6379
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres-data:
  static:
  media:

networks:
  default:
      name: wger_network

Here’s my nginx.conf too

 upstream wger {
    server web:8000;
}

server {

    listen 80;

    location / {
        proxy_pass http://wger;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }

    location /static/ {m
        alias /wger/static/;
    }

    location /media/ {
        alias /wger/media/;
    }

    # Increase max body size to allow for video uploads
    client_max_body_size 100M;

}

Which makes it look like this..

0A8DA3AB-5603-450B-AB89-BA8B14C77B96

Error 403 forbidden after login with default username and password

Good day

I am trying to login and start using my wger Docker installation, but if I login with credentials username: admin password: adminadmin, it gives me the following error:

`Forbidden (403)

CSRF verification failed. Request aborted.`

I have no idea what that means.

The following comes with the error when DEBUG is equal to TRUE:

`Help

Reason given for failure:

    Origin checking failed - https://fit.super.org.za does not match any trusted origins.
    

In general, this can occur when there is a genuine Cross Site Request Forgery, or when [Django’s CSRF mechanism](https://docs.djangoproject.com/en/4.0/ref/csrf/) has not been used correctly. For POST forms, you need to ensure:

    Your browser is accepting cookies.
    The view function passes a request to the template’s [render](https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render) method.
    In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.
    If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.
    The form has a valid CSRF token. After logging in in another browser tab or hitting the back button after a login, you may need to reload the page with the form, because the token is rotated after a login.

You’re seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.

You can customize this page using the CSRF_FAILURE_VIEW setting.`

This is my Docker-Compose file:


`#
# Please consult the `Deployment` section in the readme if you want to deploy
# this. You need to keep this nginx service, even if you have your own, otherwise
# the static files will not be served correctly!
#

services:
  web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      db:
        condition: service_healthy
      cache:
        condition: service_healthy
    env_file:
      - ./config/prod.env
    volumes:
      - static:/home/wger/static
      - media:/home/wger/media
      # For development, mount your local git checkout
      # - type: bind
      #  source: /path/to/wger/sourcecode
      #  target: /home/wger/src/
    ports:
      - "8000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  nginx:
    image: nginx:stable
    container_name: wger_nginx
    depends_on:
      - web
    volumes:
      - ./config/nginx.conf:/etc/nginx/conf.d/default.conf
      - static:/wger/static:ro
      - media:/wger/media:ro
    ports:
      - "830:80"
    healthcheck:
      test: service nginx status
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  db:
    image: postgres:12-alpine
    container_name: wger_db
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=passwordimadeup
      - POSTGRES_DB=wger
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  cache:
    image: redis
    container_name: wger_cache
    expose:
      - 6379
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres-data:
  static:
  media:

networks:
  default:
    name: wger_network`

NGINX.conf file:


`upstream wger {
    server web:8000;
}

server {

    listen 80;

    location / {
        proxy_pass http://wger;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_redirect off;
    }

    location /static/ {
        alias /wger/static/;
    }

    location /media/ {
        alias /wger/media/;
    }

    # Increase max body size to allow for video uploads
    client_max_body_size 1000M;
}`

The prod.env file:


`# Django's secret key, change to a 50 character random string if you are running
# this instance publicly. For an online generator, see e.g. https://djecrety.ir/
SECRET_KEY=a50charactersecretkey

# Signing key used for JWT, use something different than the secret key
SIGNING_KEY=a50charactersecretkey

# The 'from' address used when sending emails
[email protected]

# The server's timezone, for a list of possible names:
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIME_ZONE=Africa/Johannesburg


#
# Consult the deployment section in the readme if you are running this behind a
# reverse proxy with HTTPS enabled
#

# CSRF_TRUSTED_ORIGINS=https://my.domain.example.com,https://118.999.881.119
# X_FORWARDED_PROTO_HEADER_SET=True


#
# These settings usually don't need changing
#


#
# Application
ALLOW_REGISTRATION=True
ALLOW_GUEST_USERS=True
ALLOW_UPLOAD_VIDEOS=True
# Users won't be able to contribute to exercises if their account age is 
# lower than this amount in days.
MIN_ACCOUNT_AGE_TO_TRUST=21
# Note that setting these to true will always perform a sync during startup,
# even if the data is already current and will take some time. Usually you don't
# need to perform these steps so often and a manual trigger (see README) is
# usually enough.
SYNC_EXERCISES_ON_STARTUP=True
DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=True


#
# Database
DJANGO_DB_ENGINE=django.db.backends.postgresql
DJANGO_DB_DATABASE=wger
DJANGO_DB_USER=wger
DJANGO_DB_PASSWORD=passwordimadeup
DJANGO_DB_HOST=db
DJANGO_DB_PORT=5432
# Perform any new database migrations on startup
DJANGO_PERFORM_MIGRATIONS=True


#
# Cache
DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
DJANGO_CACHE_LOCATION=redis://cache:6379/1
# 60*60*24*15, 15 Days
DJANGO_CACHE_TIMEOUT=12
DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient

#
# Brute force login attacks
# https://django-axes.readthedocs.io/en/latest/index.html
AXES_ENABLED=True
AXES_FAILURE_LIMIT=10
# in minutes
AXES_COOLOFF_TIME=30
AXES_HANDLER=axes.handlers.cache.AxesCacheHandler

#
# Others
DJANGO_DEBUG=True
WGER_USE_GUNICORN=True
EXERCISE_CACHE_TTL=10
SITE_URL=https://mywebsiteurl


#
# JWT auth
# The lifetime duration of the access token, in minutes
ACCESS_TOKEN_LIFETIME=10
# The lifetime duration of the refresh token, in hours
REFRESH_TOKEN_LIFETIME=24


#
# Other possible settings

# RECAPTCHA_PUBLIC_KEY
# RECAPTCHA_PRIVATE_KEY
# NOCAPTCHA

# https://docs.djangoproject.com/en/4.1/topics/email/#smtp-backend
# ENABLE_EMAIL
# EMAIL_HOST
# EMAIL_PORT
# EMAIL_HOST_USER
# EMAIL_HOST_PASSWORD
# EMAIL_USE_TLS
# EMAIL_USE_SSL

# DJANGO_MEDIA_ROOT
# DJANGO_STATIC_ROOT
`

wger server container logs:


`Set site URL to https://URL

Using gunicorn...

[2023-01-03 13:11:02 +0000] [116] [INFO] Starting gunicorn 20.1.0

[2023-01-03 13:11:02 +0000] [116] [INFO] Listening at: http://0.0.0.0:8000 (116)

[2023-01-03 13:11:02 +0000] [116] [INFO] Using worker: sync

[2023-01-03 13:11:02 +0000] [117] [INFO] Booting worker with pid: 117

Forbidden (Origin checking failed - https://URL does not match any trusted origins.): /en/user/login`

wger Nginx container logs:


`v:108.0) Gecko/20100101 Firefox/108.0" "XX.XX.XX.XX"

172.30.0.1 - - [03/Jan/2023:13:13:41 +0000] "POST /en/user/login HTTP/1.1" 403 2572 "https://URL/en/user/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0" "XX.XX.XX.XX"

172.30.0.1 - - [03/Jan/2023:13:13:42 +0000] "GET /robots.txt HTTP/1.1" 200 703 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0" "XX.XX.XX.XX.XX"

172.30.0.1 - - [03/Jan/2023:13:19:58 +0000] "GET /bg/exercise/125/view/leg-raises-lying HTTP/1.1" 301 0 "-" "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)" "5.255.231.109"

172.30.0.1 - - [03/Jan/2023:13:20:00 +0000] "GET /bg/exercise/377/view-base/leg-raises-lying HTTP/1.1" 200 21690 "-" "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)" "5.255.231.109"`

wger db container logs:


`The files belonging to this database system will be owned by user "postgres".

This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".

The default database encoding has accordingly been set to "UTF8".

The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok

creating subdirectories ... ok

selecting dynamic shared memory implementation ... posix

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting default time zone ... UTC

creating configuration files ... ok

running bootstrap script ... ok

sh: locale: not found

2023-01-03 12:47:18.721 UTC [30] WARNING:  no usable system locales were found

performing post-bootstrap initialization ... ok

syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections

You can change this by editing pg_hba.conf or using the option -A, or

--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2023-01-03 12:47:20.257 UTC [36] LOG:  starting PostgreSQL 12.13 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit

2023-01-03 12:47:20.260 UTC [36] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2023-01-03 12:47:20.299 UTC [37] LOG:  database system was shut down at 2023-01-03 12:47:19 UTC

2023-01-03 12:47:20.307 UTC [36] LOG:  database system is ready to accept connections

 done

server started

CREATE DATABASE

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

2023-01-03 12:47:20.754 UTC [36] LOG:  received fast shutdown request

waiting for server to shut down....2023-01-03 12:47:20.757 UTC [36] LOG:  aborting any active transactions

2023-01-03 12:47:20.760 UTC [36] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1

2023-01-03 12:47:20.763 UTC [38] LOG:  shutting down

2023-01-03 12:47:20.787 UTC [36] LOG:  database system is shut down

 done

server stopped

PostgreSQL init process complete; ready for start up.

2023-01-03 12:47:20.883 UTC [1] LOG:  starting PostgreSQL 12.13 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit

2023-01-03 12:47:20.883 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432

2023-01-03 12:47:20.883 UTC [1] LOG:  listening on IPv6 address "::", port 5432

2023-01-03 12:47:20.892 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2023-01-03 12:47:20.950 UTC [51] LOG:  database system was shut down at 2023-01-03 12:47:20 UTC

2023-01-03 12:47:20.979 UTC [1] LOG:  database system is ready to accept connections

2023-01-03 12:47:31.513 UTC [65] ERROR:  relation "auth_user" does not exist at character 35

2023-01-03 12:47:31.513 UTC [65] STATEMENT:  SELECT COUNT(*) AS "__count" FROM "auth_user"`

PLEASE HELP!

Docker Compose Trouble - Server app - Permission Denied ./static/django_extensions

I am attempting to get the prod image running though docker compose. The driving issues is the webpage not loading after the stack starts. Going to the host IP I get redirected to 'hostIP/en/software/features'.

The error from the server logs:
PermissionError: [Errno 13] Permission denied: '/home/wger/static/django_extensions'

image

I really hope this is enough to get some troubleshooting started! Thanks for the project and the support.

Version:
Docker - 20.10.23
Compose - 2.15.1
OS - Debian GNU/Linux 11 (bullseye)

Server Logs

yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
Done in 18.37s.
yarn run v1.22.19
$ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
Done in 8.84s.
Running in production mode, running collectstatic now
Traceback (most recent call last):
  File "/home/wger/src/manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.10/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/usr/local/lib/python3.10/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 135, in collect
    handler(path, prefixed_path, storage)
  File "/usr/local/lib/python3.10/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 378, in copy_file
    self.storage.save(prefixed_path, source_file)
  File "/usr/local/lib/python3.10/dist-packages/django/core/files/storage.py", line 56, in save
    name = self._save(name, content)
  File "/usr/local/lib/python3.10/dist-packages/django/core/files/storage.py", line 295, in _save
    os.makedirs(directory, exist_ok=True)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/wger/static/django_extensions'
Performing database migrations
Operations to perform:
  Apply all migrations: actstream, auth, authtoken, axes, config, contenttypes, core, easy_thumbnails, exercises, gallery, gym, mailer, manager, measurements, nutrition, sessions, sites, weight
Running migrations:
  No migrations to apply.
  Your models in app(s): 'config' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Set site URL to http://localhost
Using gunicorn...
[2023-01-27 22:35:41 +0000] [89] [INFO] Starting gunicorn 20.1.0
[2023-01-27 22:35:41 +0000] [89] [INFO] Listening at: http://0.0.0.0:8000 (89)
[2023-01-27 22:35:41 +0000] [89] [INFO] Using worker: sync
[2023-01-27 22:35:41 +0000] [90] [INFO] Booting worker with pid: 90

nginx logs

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2023/01/27 22:34:59 [notice] 1#1: using the "epoll" event method
2023/01/27 22:34:59 [notice] 1#1: nginx/1.22.1
2023/01/27 22:34:59 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2023/01/27 22:34:59 [notice] 1#1: OS: Linux 5.15.64-1-pve
2023/01/27 22:34:59 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 524288:524288
2023/01/27 22:34:59 [notice] 1#1: start worker processes
2023/01/27 22:34:59 [notice] 1#1: start worker process 28
2023/01/27 22:34:59 [notice] 1#1: start worker process 29
2023/01/27 22:34:59 [notice] 1#1: start worker process 30
2023/01/27 22:34:59 [notice] 1#1: start worker process 31
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /en/ HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /en/software/features HTTP/1.1" 500 2767 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
2023/01/27 22:40:28 [error] 29#29: *1 open() "/wger/static/css/workout-manager.css" failed (2: No such file or directory), client: 10.0.20.13, server: , request: "GET /static/css/workout-manager.css HTTP/1.1", host: "10.0.20.65", referrer: "http://10.0.20.65/en/software/features"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /static/css/workout-manager.css HTTP/1.1" 404 153 "http://10.0.20.65/en/software/features" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /static/yarn/bootstrap-compiled.css HTTP/1.1" 404 153 "http://10.0.20.65/en/software/features" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
2023/01/27 22:40:28 [error] 29#29: *1 open() "/wger/static/yarn/bootstrap-compiled.css" failed (2: No such file or directory), client: 10.0.20.13, server: , request: "GET /static/yarn/bootstrap-compiled.css HTTP/1.1", host: "10.0.20.65", referrer: "http://10.0.20.65/en/software/features"
2023/01/27 22:40:28 [error] 30#30: *5 open() "/wger/static/css/bootstrap-custom.css" failed (2: No such file or directory), client: 10.0.20.13, server: , request: "GET /static/css/bootstrap-custom.css HTTP/1.1", host: "10.0.20.65", referrer: "http://10.0.20.65/en/software/features"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /static/css/bootstrap-custom.css HTTP/1.1" 404 153 "http://10.0.20.65/en/software/features" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /static/yarn/shariff/dist/shariff.min.js HTTP/1.1" 404 153 "http://10.0.20.65/en/software/features" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
2023/01/27 22:40:28 [error] 30#30: *5 open() "/wger/static/yarn/shariff/dist/shariff.min.js" failed (2: No such file or directory), client: 10.0.20.13, server: , request: "GET /static/yarn/shariff/dist/shariff.min.js HTTP/1.1", host: "10.0.20.65", referrer: "http://10.0.20.65/en/software/features"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /static/images/logos/logo-bg-white.png HTTP/1.1" 404 153 "http://10.0.20.65/en/software/features" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"
2023/01/27 22:40:28 [error] 30#30: *5 open() "/wger/static/images/logos/logo-bg-white.png" failed (2: No such file or directory), client: 10.0.20.13, server: , request: "GET /static/images/logos/logo-bg-white.png HTTP/1.1", host: "10.0.20.65", referrer: "http://10.0.20.65/en/software/features"
2023/01/27 22:40:28 [error] 29#29: *1 open() "/wger/static/images/favicon.png" failed (2: No such file or directory), client: 10.0.20.13, server: , request: "GET /static/images/favicon.png HTTP/1.1", host: "10.0.20.65", referrer: "http://10.0.20.65/en/software/features"
10.0.20.13 - - [27/Jan/2023:22:40:28 +0000] "GET /static/images/favicon.png HTTP/1.1" 404 153 "http://10.0.20.65/en/software/features" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"

db logs

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-01-27 22:34:47.292 UTC [1] LOG:  starting PostgreSQL 12.13 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit

2023-01-27 22:34:47.292 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432

2023-01-27 22:34:47.292 UTC [1] LOG:  listening on IPv6 address "::", port 5432

2023-01-27 22:34:47.296 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2023-01-27 22:34:47.330 UTC [21] LOG:  database system was shut down at 2023-01-27 22:22:36 UTC

2023-01-27 22:34:47.340 UTC [1] LOG:  database system is ready to accept connections

cache logs

1:C 27 Jan 2023 22:34:47.153 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 27 Jan 2023 22:34:47.153 # Redis version=7.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 27 Jan 2023 22:34:47.153 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 27 Jan 2023 22:34:47.155 * monotonic clock: POSIX clock_gettime
1:M 27 Jan 2023 22:34:47.157 * Running mode=standalone, port=6379.
1:M 27 Jan 2023 22:34:47.157 # Server initialized
1:M 27 Jan 2023 22:34:47.157 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 27 Jan 2023 22:34:47.158 * Ready to accept connections
1:M 27 Jan 2023 22:39:48.082 * 100 changes in 300 seconds. Saving...
1:M 27 Jan 2023 22:39:48.083 * Background saving started by pid 219
219:C 27 Jan 2023 22:39:48.089 * DB saved on disk
219:C 27 Jan 2023 22:39:48.090 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
1:M 27 Jan 2023 22:39:48.183 * Background saving terminated with success
1:M 27 Jan 2023 22:44:49.047 * 100 changes in 300 seconds. Saving...
1:M 27 Jan 2023 22:44:49.047 * Background saving started by pid 428
428:C 27 Jan 2023 22:44:49.055 * DB saved on disk
428:C 27 Jan 2023 22:44:49.056 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
1:M 27 Jan 2023 22:44:49.148 * Background saving terminated with success
1:M 27 Jan 2023 22:49:50.055 * 100 changes in 300 seconds. Saving...
1:M 27 Jan 2023 22:49:50.055 * Background saving started by pid 635
635:C 27 Jan 2023 22:49:50.069 * DB saved on disk
635:C 27 Jan 2023 22:49:50.070 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
1:M 27 Jan 2023 22:49:50.156 * Background saving terminated with success

docker-compose.yml

#
# Please consult the `Deployment` section in the readme if you want to deploy
# this. You need to keep this nginx service, even if you have your own, otherwise
# the static files will not be served correctly!
#

services:
  web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      db:
        condition: service_healthy
      cache:
        condition: service_healthy
    env_file:
      - ./config/prod.env
    volumes:
      - ./static:/home/wger/static
      - ./media:/home/wger/media
      # For development, mount your local git checkout
      # - type: bind
      #  source: /path/to/wger/sourcecode
      #  target: /home/wger/src/
    ports:
      - "8000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  nginx:
    image: nginx:stable
    container_name: wger_nginx
    depends_on:
      - web
    volumes:
      - ./config/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./static:/wger/static:ro
      - ./media:/wger/media:ro
    ports:
      - "80:80"
    healthcheck:
      test: service nginx status
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  db:
    image: postgres:12-alpine
    container_name: wger_db
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=wger
      - POSTGRES_DB=wger
    volumes:
      - ./postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  cache:
    image: redis
    container_name: wger_cache
    expose:
      - 6379
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres-data:
  static:
  media:

networks:
  default:
    name: wger_network

nginx.conf

upstream wger {
    server web:8000;
}

server {

    listen 80;

    location / {
        proxy_pass http://wger;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_redirect off;
    }

    location /static/ {
        alias /wger/static/;
    }

    location /media/ {
        alias /wger/media/;
    }

    # Increase max body size to allow for video uploads
    client_max_body_size 100M;
}

prod.env

# Django's secret key, change to a 50 character random string if you are running
# this instance publicly. For an online generator, see e.g. https://djecrety.ir/
SECRET_KEY=**[censored]**

# Signing key used for JWT, use something different than the secret key
SIGNING_KEY=**[censored]**

# The 'from' address used when sending emails
FROM_EMAIL=**[censored]**

# The server's timezone, for a list of possible names:
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIME_ZONE=**[censored]**


#
# Consult the deployment section in the readme if you are running this behind a
# reverse proxy with HTTPS enabled
#

# CSRF_TRUSTED_ORIGINS=https://my.domain.example.com,https://118.999.881.119
# X_FORWARDED_PROTO_HEADER_SET=True


#
# These settings usually don't need changing
#


#
# Application
ALLOW_REGISTRATION=True
ALLOW_GUEST_USERS=True
ALLOW_UPLOAD_VIDEOS=True
# Users won't be able to contribute to exercises if their account age is
# lower than this amount in days.
MIN_ACCOUNT_AGE_TO_TRUST=21
# Note that setting these to true will always perform a sync during startup,
# even if the data is already current and will take some time. Usually you don't
# need to perform these steps so often and a manual trigger (see README) is
# usually enough.
SYNC_EXERCISES_ON_STARTUP=False
DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=False


#
# Database
DJANGO_DB_ENGINE=django.db.backends.postgresql
DJANGO_DB_DATABASE=wger
DJANGO_DB_USER=wger
DJANGO_DB_PASSWORD=wger
DJANGO_DB_HOST=db
DJANGO_DB_PORT=5432
# Perform any new database migrations on startup
DJANGO_PERFORM_MIGRATIONS=True


#
# Cache
DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
DJANGO_CACHE_LOCATION=redis://cache:6379/1
# 60*60*24*15, 15 Days
DJANGO_CACHE_TIMEOUT=12
DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient

#
# Brute force login attacks
# https://django-axes.readthedocs.io/en/latest/index.html
AXES_ENABLED=True
AXES_FAILURE_LIMIT=10
# in minutes
AXES_COOLOFF_TIME=30
AXES_HANDLER=axes.handlers.cache.AxesCacheHandler

#
# Others
DJANGO_DEBUG=False
WGER_USE_GUNICORN=True
EXERCISE_CACHE_TTL=10
SITE_URL=http://localhost

#
# JWT auth
# The lifetime duration of the access token, in minutes
ACCESS_TOKEN_LIFETIME=10
# The lifetime duration of the refresh token, in hours
REFRESH_TOKEN_LIFETIME=24


#
# Other possible settings

# RECAPTCHA_PUBLIC_KEY
# RECAPTCHA_PRIVATE_KEY
# NOCAPTCHA

# https://docs.djangoproject.com/en/4.1/topics/email/#smtp-backend
# ENABLE_EMAIL
# EMAIL_HOST
# EMAIL_PORT
# EMAIL_HOST_USER
# EMAIL_HOST_PASSWORD
# EMAIL_USE_TLS
# EMAIL_USE_SSL

# DJANGO_MEDIA_ROOT
# DJANGO_STATIC_ROOT

"An error has occcured!" Produced on webgui

image
This is showing up when I go to my WebGUI

Not really seeing any errors as such in the logs just this when i try to access to UI

#
# Please consult the `Deployment` section in the readme if you want to deploy
# this. You need to keep this nginx service, even if you have your own, otherwise
# the static files will not be served correctly!
#

services:
  web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      db:
        condition: service_healthy
      cache:
        condition: service_healthy
    env_file:
      - stack.env
    volumes:
      - static:/home/wger/static
      - media:/home/wger/media
      # For development, mount your local git checkout
      # - type: bind
      #  source: /path/to/wger/sourcecode
      #  target: /home/wger/src/
    ports:
      - "8005:8000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  nginx:
    image: nginx:stable
    container_name: wger_nginx
    env_file:
      - stack.env
    depends_on:
      - web
    volumes:
      - ./config/nginx:/etc/nginx/conf.d/
      - static:/wger/static:ro
      - media:/wger/media:ro
    ports:
      - "80:80"
    healthcheck:
      test: service nginx status
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  db:
    image: postgres:12-alpine
    container_name: wger_db
    env_file:
      - stack.env
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=wger
      - POSTGRES_DB=wger
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    expose:
      - 5432
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  cache:
    image: redis
    env_file:
      - stack.env
    container_name: wger_cache
    expose:
      - 6379
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres-data:
  static:
  media:

networks:
  default:
    name: wger_network

Copy of my docker-compose I used.

Data not persistent across reboots

After I restarted my docker container, my users data did not persist. I can see 3 users (default admin, the pre-reboot admin, the pre-reboot user) but the pre-reboot users names are some random alphanumeric string, and I can't login with the username/password I had setup previously.

I had only started using it, so I'm not sure about the other workout data. But I am wondering what else I need to do/may have missed to make this persistent across restarts of the container.

My docker-compose.yml:

  1   version: '3.7' 
  2   services:
  3   wger:
  4     container_name: wger
  5     image: wger/server:latest
  6     volumes:
  7       - ./static:/home/wger/static
  8       - ./media:/home/wger/media
  9     ports:
 10       - 8097:8000
 11     environment:
 12       PUID: 1000
 13       PGID: 1000
 14       TZ: Australia/Sydney
 15     env_file:
 16       - ./prod.env
 17     depends_on:
 18       - db
 19       - cache
 20     restart: unless-stopped
 21
 22   db:
 23     image: postgres:12-alpine
 24     volumes:
 25       - ./postgres-data:/var/lib/postgresql/data/
 26     expose:
 27       - 5432
 28     environment:
 29       - POSTGRES_USER=wger
 30       - POSTGRES_PASSWORD=wger
 31       - POSTGRES_DB=wger
 32
 33   cache:
 34     restart: unless-stopped
 35     image: redis:latest
 36     expose:
 37       - 6379

settings.py overwritten by settings_global

Needing some help with the latest update and migration. Everything went well.

My only issue is that the settings.py or prod.env is being overwritten or not applied by settings.global.

Any insight on why or what I can do to fix this?

Thanks

Exercises Not Syncing

Hello,

I'm having a similar issue as #36 but the steps used to resolve the error don't seem to be fully working for me. Not sure what to do next any info would be greatly appreciated! Logs from the docker container:

`yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
Done in 7.11s.
yarn run v1.22.19
$ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
Done in 3.52s.
Running in production mode, running collectstatic now
5726 static files copied to '/home/wger/static', 10012 unmodified.
Synchronizing exercises
*** Synchronizing languages...
done!
*** Synchronizing categories...
done!
*** Synchronizing muscles...
done!
*** Synchronizing equipment...
done!
*** Synchronizing exercises...
updated exercise cfb6a754-57be-431b-b8d0-d9963120bd5a

  • updated translation cs 0fe97ed6-7d37-444c-90b6-f855cea68a6f - Barbell Wrist Curl
  • updated translation ca 5afb7241-2eb9-4c9e-aa8f-b0b9bc8a0797 - Handgelenkstreckung
    updated exercise 1b020b3a-3732-4c7e-92fd-a0cec90ed69b
  • updated translation cs c788d643-150a-4ac7-97ef-84643c6419bf - 2 Handed Kettlebell Swing
    updated exercise f2733700-aa5d-4df7-bc52-1876ab4fb479
  • updated translation cs 6add5973-86d0-4543-928a-6bb8b3f34efc - Axe Hold
  • updated translation ca 8e9d8968-323d-468c-9174-8cf11a105fad - Axe Hold
    updated exercise 03db11cc-8079-463c-9399-6f346b100ce6
  • updated translation cs 60d8018d-296f-4c62-a80b-f609a25d34ea - Abdominal Stabilization
  • updated translation ca c659577f-d9de-4e39-bcd1-1b0bf1f62d11 - Bauch Stabilisation
    updated exercise ea63d85c-8579-4dda-b99f-c4c8930f9af6
  • updated translation cs 51595d74-afe2-4445-88ec-2a289251e710 - Tricep Pushdown on Cable
    updated exercise 9e6dae29-5d03-440a-bdf1-2cb25a5179c2
  • updated translation ru 4ef74871-44bb-43b3-acfb-8c221ad06bd2 - Adım atma
  • updated translation sv f8720d72-e04e-4008-bdae-77d791d26ae4 - Marches
  • updated translation fr 2c500679-beaa-4717-baf8-b2eab2b1bc89 - Opstappen
  • updated translation it 1155ce91-a11b-488d-8751-ffb0e403fcbe - Progressos
  • updated translation ca 1cc35af7-6ddf-4a1c-82f3-1974087cb2ee - Steigungen
  • updated translation tr a35e8b34-4c04-47ea-bf71-e19af6872dda - Step
    Traceback (most recent call last):
    File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 929, in get_or_create
    return self.get(**kwargs), False
    File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 650, in get
    raise self.model.DoesNotExist(
    wger.exercises.models.exercise.Exercise.DoesNotExist: Exercise matching query does not exist.
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
    File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 306, in _commit
    return self.connection.commit()
    psycopg2.errors.ForeignKeyViolation: insert or update on table "exercises_exercise" violates foreign key constraint "exercises_exercise_language_id_9675c687_fk_core_language_id"
    DETAIL: Key (language_id)=(23) is not present in table "core_language".
    The above exception was the direct cause of the following exception:
    Traceback (most recent call last):
    File "/home/wger/src/manage.py", line 25, in
    execute_from_command_line(sys.argv)
    File "/usr/local/lib/python3.10/dist-packages/django/core/management/init.py", line 446, in execute_from_command_line
    utility.execute()
    File "/usr/local/lib/python3.10/dist-packages/django/core/management/init.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
    File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
    File "/home/wger/src/wger/exercises/management/commands/sync-exercises.py", line 106, in handle
    self.sync_exercises()
    File "/home/wger/src/wger/exercises/management/commands/sync-exercises.py", line 146, in sync_exercises
    translation, translation_created = Exercise.objects.get_or_create(
    File "/usr/local/lib/python3.10/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 934, in get_or_create
    with transaction.atomic(using=self.db):
    File "/usr/local/lib/python3.10/dist-packages/django/db/transaction.py", line 262, in exit
    connection.commit()
    File "/usr/local/lib/python3.10/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
    File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 330, in commit
    self._commit()
    File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 305, in _commit
    with self.wrap_database_errors:
    File "/usr/local/lib/python3.10/dist-packages/django/db/utils.py", line 91, in exit
    raise dj_exc_value.with_traceback(traceback) from exc_value
    File "/usr/local/lib/python3.10/dist-packages/django/db/backends/base/base.py", line 306, in _commit
    return self.connection.commit()
    django.db.utils.IntegrityError: insert or update on table "exercises_exercise" violates foreign key constraint "exercises_exercise_language_id_9675c687_fk_core_language_id"
    DETAIL: Key (language_id)=(23) is not present in table "core_language".
    Downloading exercise images
    *** Processing images ***
    *** Page 1
    Processing image ef0b00e2-3323-4e7f-88fe-d71ef34b3384
    Remote exercise base not found in local DB, skipping...
    Processing image bed4f21b-28be-4ef1-bd88-1a4e3db66c5c
    Remote exercise base not found in local DB, skipping...
    Processing image 59efcec2-a7ce-40ba-bf2b-1a6eabe52fbd
    Remote exercise base not found in local DB, skipping...
    Processing image 1c37e4e1-5144-4a50-8294-16180a9bc767
    Remote exercise base not found in local DB, skipping...
    Processing image 065f9418-6245-46ae-8e24-b4013ce084e4
    Remote exercise base not found in local DB, skipping...
    Processing image ca71df8e-a6d6-453f-a25a-f4cebae3b970
    Image not found in local DB, creating now...
    successfully saved
    Processing image 7276a19e-06d0-45ae-a2a3-569bed75686b
    Image not found in local DB, creating now...
    successfully saved
    Processing image c64a9199-5ad7-4552-abdd-491deb02296a
    Remote exercise base not found in local DB, skipping...
    Processing image dd0a0445-11cf-45d3-bbd1-6ae0add6b39c
    Remote exercise base not found in local DB, skipping...
    Processing image f22c1928-fc70-4595-b090-af73e7a019fe
    Remote exercise base not found in local DB, skipping...
    Processing image aa574839-4a7e-4c0d-ac72-2f7448478a1c
    Remote exercise base not found in local DB, skipping...
    Processing image 4545b1ab-bf7f-4626-894e-b801047f2fa9
    Remote exercise base not found in local DB, skipping...
    Processing image f3ea8468-02df-4022-a8ef-17700c98d63c
    Remote exercise base not found in local DB, skipping...
    Processing image ad26f561-e80b-43e2-93ed-07c0fba63a3d
    Remote exercise base not found in local DB, skipping...
    Processing image a02c9c7d-f42d-43e0-9946-1b99b014daee
    Remote exercise base not found in local DB, skipping...
    Processing image 08517378-bc36-4f6b-9952-1f45a02d936e
    Remote exercise base not found in local DB, skipping...
    Processing image 6c1a7459-266d-491a-bd50-7cbaea2bc771
    Remote exercise base not found in local DB, skipping...
    Processing image 94347272-2ea7-407f-9362-cde777bc908d
    Remote exercise base not found in local DB, skipping...
    Processing image 63da5c54-7f1d-4a09-9867-2bdda2a6ddeb
    Remote exercise base not found in local DB, skipping...
    Processing image 90e32fa6-a90d-46b3-8ea8-c9ec8e666eca
    Remote exercise base not found in local DB, skipping...
    *** Page 2
    Processing image c74c43a5-da29-443d-895c-2900b5591cd2
    Remote exercise base not found in local DB, skipping...
    Processing image ed7c3729-22ce-425e-a0ad-108963a35c7a
    Remote exercise base not found in local DB, skipping...
    Processing image 285943a6-e0ce-47cc-b244-ba698377af93
    Remote exercise base not found in local DB, skipping...
    Processing image 4ddb899f-0acb-46b3-b110-d0aac701bc60
    Remote exercise base not found in local DB, skipping...
    Processing image 40212645-0278-4c1d-9f7a-a00ee4d12314
    Remote exercise base not found in local DB, skipping...
    Processing image 87a312b7-d01e-4f69-9bda-1ed2f1fcd9ab
    Remote exercise base not found in local DB, skipping...
    Processing image 06cba35d-3c10-4e13-ae1c-524dbb194fdf
    Remote exercise base not found in local DB, skipping...
    Processing image 8d42f527-b6ca-4749-9db9-94af1413cc2c
    Remote exercise base not found in local DB, skipping...
    Processing image b0e8b77a-97c2-470f-9fc0-928ffb2aae89
    Remote exercise base not found in local DB, skipping...
    Processing image 17e5d7a3-d94c-41dd-830d-15a5e1834dff
    Remote exercise base not found in local DB, skipping...
    Processing image 1503e8e3-b67a-4e74-b044-99288eb26f44
    Remote exercise base not found in local DB, skipping...
    Processing image 3cc89c05-19fe-4598-bb0c-24d36ef9c1d6
    Remote exercise base not found in local DB, skipping...
    Processing image 70761be3-c07e-4dac-a0a6-b62b4e3c0ab6
    Remote exercise base not found in local DB, skipping...
    Processing image c69477af-3337-46f1-819d-73a10c51e136
    Remote exercise base not found in local DB, skipping...
    Processing image c0e334a0-25f4-4057-8dee-c6efeeabcf13
    Remote exercise base not found in local DB, skipping...
    Processing image 10975be2-fbb5-40ea-8c72-22f7466d9e5a
    Remote exercise base not found in local DB, skipping...
    Processing image d3e26e7c-7ef6-443d-a2bf-5b0a06fe2d29
    Remote exercise base not found in local DB, skipping...
    Processing image deeecd20-53f7-4494-a531-e6ff8cd79045
    Remote exercise base not found in local DB, skipping...
    Processing image a067edbd-c5e9-42be-8ce3-238c0a4760f6
    Remote exercise base not found in local DB, skipping...
    Processing image 66ff858e-3719-4fdc-9710-c41e43a3c057
    Remote exercise base not found in local DB, skipping...
    *** Page 3
    Processing image 0aecd2f4-3016-4813-b3c0-6a708ae7069a
    Remote exercise base not found in local DB, skipping...
    Processing image 4371e111-5b1f-4679-968e-bb5d9a48ebe2
    Remote exercise base not found in local DB, skipping...
    Processing image fd35994a-70b4-4ca4-b236-12c178062996
    Remote exercise base not found in local DB, skipping...
    Processing image 1fbfbec9-2431-45db-8ca7-a8e477add80f
    Remote exercise base not found in local DB, skipping...
    Processing image aa645b51-beb3-4397-94d6-d1abee8be6db
    Remote exercise base not found in local DB, skipping...
    Processing image e07c2ca5-a85f-4921-b590-39de7aa9b62a
    Remote exercise base not found in local DB, skipping...
    Processing image 34600351-8b0b-4cb0-8daa-583537be15b0
    Remote exercise base not found in local DB, skipping...
    Processing image 2fc242d3-5bdd-4f97-99bd-678adb8c96fc
    Remote exercise base not found in local DB, skipping...
    Processing image 2e959dab-f39b-4c7c-9063-eb43064ab5eb
    Remote exercise base not found in local DB, skipping...
    Processing image 74affc0d-03b6-4f33-b5f4-a822a2615f68
    Remote exercise base not found in local DB, skipping...
    Processing image ad724e5c-b1ed-49e8-9279-a17545b0dd0b
    Remote exercise base not found in local DB, skipping...
    Processing image 119e6823-6960-4341-a9e1-aaf78d7fb57c
    Remote exercise base not found in local DB, skipping...
    Processing image 783d980c-af07-4ac0-a525-6dc8c426a204
    Remote exercise base not found in local DB, skipping...
    Processing image f934a652-49e1-4c74-877d-682c26c4d278
    Remote exercise base not found in local DB, skipping...
    Processing image d4b50a4d-cade-4b48-9e6c-7b1a5a822b2a
    Remote exercise base not found in local DB, skipping...
    Processing image 1d3b1662-61dc-41cf-acec-ca4c86ace3eb
    Remote exercise base not found in local DB, skipping...
    Processing image 2ea6fd82-46f7-4f9a-97e5-b704e6efc469
    Remote exercise base not found in local DB, skipping...
    Processing image 7b392101-9c47-4693-935e-a88b1887eec5
    Remote exercise base not found in local DB, skipping...
    Processing image 0fd94587-6021-4763-856e-7227f5fcba2a
    Remote exercise base not found in local DB, skipping...
    Processing image 53a5e008-bc31-4ee0-9463-69a858c2ec18
    Remote exercise base not found in local DB, skipping...
    *** Page 4
    Processing image 0fdc1eea-07d1-4d01-8d89-6c39673dcbed
    Remote exercise base not found in local DB, skipping...
    Processing image 1cdfd1d7-4cfc-424f-99bd-a851655355fc
    Remote exercise base not found in local DB, skipping...
    Processing image 046ad15d-e908-43b9-91e2-b8223d4322fa
    Remote exercise base not found in local DB, skipping...
    Processing image 4b3c5bf6-ea2a-4fa4-a3cb-98979c1f380a
    Remote exercise base not found in local DB, skipping...
    Processing image 061cf07e-96a3-4063-8bd5-7abcdb047a99
    Remote exercise base not found in local DB, skipping...
    Processing image 13fbda16-5ef6-4f48-b58c-954c3078001c
    Image not found in local DB, creating now...
    successfully saved
    Processing image c9fee9d3-0b0e-40ae-a9c7-a4033781ea3b
    Image not found in local DB, creating now...
    successfully saved
    Processing image e543fb73-06d0-4e1b-8645-d5706da9504a
    Remote exercise base not found in local DB, skipping...
    Processing image 5f318812-108b-402c-bca3-6e409af076c7
    Remote exercise base not found in local DB, skipping...
    Processing image 11db76be-b05f-4dae-8d2a-2b3135cc88b5
    Remote exercise base not found in local DB, skipping...
    Processing image 75382eaf-468f-4c21-8710-6bf475d8ecc2
    Remote exercise base not found in local DB, skipping...
    Processing image b2fde283-2a29-4951-8f64-442785c03078
    Remote exercise base not found in local DB, skipping...
    Processing image 57e8edbe-365b-4824-b2e4-b4de197c7628
    Remote exercise base not found in local DB, skipping...
    Processing image c205b132-b4f1-4e2c-b869-9b3f897bda9c
    Remote exercise base not found in local DB, skipping...
    Processing image af848376-3db3-4b16-a056-4aa936d49da4
    Remote exercise base not found in local DB, skipping...
    Processing image 41e5c58e-0325-4620-8d96-7372cc4dae8c
    Remote exercise base not found in local DB, skipping...
    Processing image b2c5a9f9-8beb-41f7-841c-9664d22a427e
    Remote exercise base not found in local DB, skipping...
    Processing image b4dfc3fb-c049-418f-855d-23ab6c39d906
    Remote exercise base not found in local DB, skipping...
    Processing image 87733a46-17db-4ca1-b2dc-80c5976a5627
    Remote exercise base not found in local DB, skipping...
    Processing image 492ce9c7-12cf-4378-aca4-fe008dea5dd4
    Remote exercise base not found in local DB, skipping...
    *** Page 5
    Processing image 3c774680-b68c-4b1c-a150-4858783661c7
    Remote exercise base not found in local DB, skipping...
    Processing image c91ed07b-630b-427d-94cc-c55cdb71024a
    Remote exercise base not found in local DB, skipping...
    Processing image cb9267bb-f561-49a2-94ad-fa4adebf1e27
    Remote exercise base not found in local DB, skipping...
    Processing image 752caaf6-ec3d-4075-a4b3-65ec5b1922c8
    Remote exercise base not found in local DB, skipping...
    Processing image 3e255a5f-b058-4a09-b0b0-70044285528a
    Remote exercise base not found in local DB, skipping...
    Processing image 3c765b1e-eab9-4b61-8e2e-7d7591cb6ccb
    Remote exercise base not found in local DB, skipping...
    Processing image 5e6aa692-cb40-45f5-a17c-b368c3bd2d3f
    Remote exercise base not found in local DB, skipping...
    Processing image 52c61306-43c0-4f1e-bf03-13074c152dd8
    Remote exercise base not found in local DB, skipping...
    Processing image 52c4434e-b5a2-4fce-af61-d997b510438a
    Remote exercise base not found in local DB, skipping...
    Processing image 3d311933-e073-409b-92d3-41f3d75e8c94
    Remote exercise base not found in local DB, skipping...
    Processing image c0dff0d5-618d-4739-94f9-7d3cd76bc8a1
    Remote exercise base not found in local DB, skipping...
    Processing image 0dab623c-75f1-45a6-ba24-d80d42e5d284
    Remote exercise base not found in local DB, skipping...
    Processing image 8fb4de34-d4df-435a-bf59-14410ebda230
    Remote exercise base not found in local DB, skipping...
    Processing image dc2cf50c-6452-4a8f-91e2-6114fcc425ff
    Remote exercise base not found in local DB, skipping...
    Processing image 081d1f56-c664-4493-9846-b6d6613e0ef7
    Remote exercise base not found in local DB, skipping...
    Processing image 7cd81b4a-15f1-464d-96db-c2f01152fb04
    Remote exercise base not found in local DB, skipping...
    Processing image 9d5d511e-d0a1-45e7-b656-07b0b86541d4
    Remote exercise base not found in local DB, skipping...
    Processing image a1b5b12d-06ab-4e80-93bc-352da6aec7f5
    Remote exercise base not found in local DB, skipping...
    Processing image 545a71c9-440d-442d-b772-1458eb4f1125
    Remote exercise base not found in local DB, skipping...
    Processing image bec83f17-2060-4bee-8a02-78db230568bf
    Remote exercise base not found in local DB, skipping...
    *** Page 6
    Processing image dd63c466-ea7e-47f4-b1b2-8a50b4656dfc
    Remote exercise base not found in local DB, skipping...
    Processing image 01a05758-9b0b-4d9c-b5a6-80b9df6bd26a
    Remote exercise base not found in local DB, skipping...
    Processing image 1983b6be-1784-4ad3-a05c-7e4b34d9878f
    Remote exercise base not found in local DB, skipping...
    Processing image 239d43a2-b86f-4dc7-aab2-27c8c2f7de47
    Remote exercise base not found in local DB, skipping...
    Processing image f8d23bc0-4b42-40fb-aa01-970fb573a212
    Remote exercise base not found in local DB, skipping...
    Processing image d7c5c697-8a93-4d69-8c9d-a919cb4e1f77
    Remote exercise base not found in local DB, skipping...
    Processing image a7d82572-ca40-4616-a13d-a359d7efae20
    Remote exercise base not found in local DB, skipping...
    Processing image aa0ff663-f593-465e-9fce-c01b77c6eb9c
    Remote exercise base not found in local DB, skipping...
    Processing image c6464fb3-1924-4ff1-adfa-fd36da9b5d13
    Remote exercise base not found in local DB, skipping...
    Processing image abfc7700-fadf-4f2d-ac84-e045e590a2fe
    Remote exercise base not found in local DB, skipping...
    Processing image 6a770e5d-cd62-4754-a18c-eebe2103d7c5
    Remote exercise base not found in local DB, skipping...
    Processing image 692c598c-0493-42a5-be8b-b9d2e9adcd00
    Remote exercise base not found in local DB, skipping...
    Processing image 2e69c005-b241-4806-8557-fc5a4d5ee44d
    Remote exercise base not found in local DB, skipping...
    Processing image 30b2631d-d7ec-415c-800b-7eb082314c0a
    Remote exercise base not found in local DB, skipping...
    Processing image a3073a56-3099-42e6-8964-7a19fb3f6237
    Remote exercise base not found in local DB, skipping...
    Processing image 611eef29-39f3-4a8b-ae37-fb78abfa1a11
    Remote exercise base not found in local DB, skipping...
    Processing image 01dd27bc-17d5-48c9-840b-c77418d207cd
    Remote exercise base not found in local DB, skipping...
    Processing image 4744270a-73a0-4e45-8af8-52df29cc14fb
    Remote exercise base not found in local DB, skipping...
    Processing image a6d6d740-eb6c-4a0d-ac28-72ad03abf76a
    Remote exercise base not found in local DB, skipping...
    Set site URL to http://localhost
    Using gunicorn...
    [2023-02-06 05:27:00 +0000] [88] [INFO] Starting gunicorn 20.1.0
    [2023-02-06 05:27:00 +0000] [88] [INFO] Listening at: http://0.0.0.0:8000 (88)
    [2023-02-06 05:27:00 +0000] [88] [INFO] Using worker: sync
    [2023-02-06 05:27:00 +0000] [89] [INFO] Booting worker with pid: 89`

Django permission error

Can this help track down any permission errors on static or django?

wger | yarn install v1.22.19
wger | [1/5] Validating package.json...
wger | [2/5] Resolving packages...
wger | [3/5] Fetching packages...
wger | [4/5] Linking dependencies...
wger | [5/5] Building fresh packages...
wger | Done in 42.34s.
wger | yarn run v1.22.19
wger | $ sass wger/core/static/scss/main.scss:wger/core/static/yarn/bootstrap-compiled.css
wger | Done in 14.57s.
wger | Running in production mode, running collectstatic now
wger | Traceback (most recent call last):
wger | File "/home/wger/src/manage.py", line 25, in
wger | execute_from_command_line(sys.argv)
wger | File "/usr/local/lib/python3.10/dist-packages/django/core/management/init.py", line 419, in execute_from_command_line
wger | utility.execute()
wger | File "/usr/local/lib/python3.10/dist-packages/django/core/management/init.py", line 413, in execute
wger | self.fetch_command(subcommand).run_from_argv(self.argv)
wger | File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 354, in run_from_argv
wger | self.execute(*args, **cmd_options)
wger | File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 398, in execute
wger | output = self.handle(*args, **options)
wger | File "/usr/local/lib/python3.10/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
wger | collected = self.collect()
wger | File "/usr/local/lib/python3.10/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
wger | handler(path, prefixed_path, storage)
wger | File "/usr/local/lib/python3.10/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 348, in copy_file
wger | self.storage.save(prefixed_path, source_file)
wger | File "/usr/local/lib/python3.10/dist-packages/django/core/files/storage.py", line 54, in save
wger | name = self._save(name, content)
wger | File "/usr/local/lib/python3.10/dist-packages/django/core/files/storage.py", line 260, in _save
wger | os.makedirs(directory, exist_ok=True)
wger | File "/usr/lib/python3.10/os.py", line 215, in makedirs
wger | makedirs(head, exist_ok=exist_ok)
wger | File "/usr/lib/python3.10/os.py", line 225, in makedirs
wger | mkdir(name, mode)
wger | PermissionError: [Errno 13] Permission denied: '/home/wger/static/django_extensions'
wger | Performing database migrations
wger | Operations to perform:
wger | Apply all migrations: actstream, auth, authtoken, axes, config, contenttypes, core, easy_thumbnails, exercises, gallery, gym, mailer, manager, measurements, nutrition, sessions, sites, weight

Setting up email

It seems the FROM_EMAIL is getting lost somewhere:

Discussed in #33

Originally posted by TryCatchCrash October 23, 2022
I've set up prod.env for email (i know the settings are fine since i have a non-docker instance running and sending mails with the same settings) and it seems to ignore the FROM_EMAIL setting.

I see in the wger_server log:
smtplib.SMTPDataError: (553, b'Relaying disallowed as [email protected]')

FROM_EMAIL is set to admin@<mydomain.ext>

Am I doing something wrong or is this a bug?

WGER html format white background

Hi all, i have a question.

I am kind of new with docker.
I have deployed my wger docker, all seems fine, but i don't see a nice html background. it's plain text with a white background.
wger docker no html

This is local and from external.
I had disabled the nginx container and configured my nginx proxy manager to handle external traffic.

English is not my native language.

Kind regards, Nick

Workout - cannot add untranslated excercises

Problem:

When adding excercises to a workout and having language set to Czech, I can't find excercises that are not translated. Workaround is switching to English, no problem there.

Here is an excersise not translated to czech.
image

Here is a screenshot of me trying to add this excersise to a workout.
image

Environment:

I'm running the latest release in docker, excercises pullled this morning. My language is mostly set to Czech, but due to some problems, I switch to English.

CSFR-Verification

Hi!

I'm running the docker-compose image of wger behind NPM.
Today I updated the images, and now I get the error "403 CSFR-Verification failed".

I updated docker-compose.yml, prod.env and nginx.conf as well and rebuilt - still same problem.
After rollback to my backup, usage of wger through NPM works perfectly fine again.

Can you help me fix this issue?

Kind regards!

No persistant data

Hi, running into an issue with persistant data. I copied the persistant location via the docker-compose file. I get the docker running, but if I update the image all my data is gone. My static locations and media locations are all empty. Any thoughts or ideas?

Thanks

unable to stand up web service on raspberry pi

I've followed the instructions for "1 - Start":

docker-compose up -d
docker-compose exec web python3 manage.py sync-exercises
docker-compose exec web python3 manage.py download-exercise-images
docker-compose exec web wger load-online-fixtures

However, no web service was found.
image

Log Output:

pi@wgerpi:~/projects/wger-docker $ sudo docker-compose up -d
Creating network "wger-docker_default" with the default driver
Creating wger-docker_cache_1 ... done
Creating wger-docker_db_1    ... done
Creating wger-docker_web_1   ... done
Creating wger-docker_nginx_1 ... done
pi@wgerpi:~/projects/wger-docker $ sudo docker-compose logs -f
Attaching to wger-docker_nginx_1, wger-docker_web_1, wger-docker_cache_1, wger-docker_db_1
db_1     | 
db_1     | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1     | 
db_1     | 2021-09-17 17:14:43.246 UTC [1] LOG:  starting PostgreSQL 12.8 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit
db_1     | 2021-09-17 17:14:43.246 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1     | 2021-09-17 17:14:43.246 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1     | 2021-09-17 17:14:44.556 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1     | 2021-09-17 17:14:44.648 UTC [22] LOG:  database system was shut down at 2021-09-17 17:01:45 UTC
db_1     | 2021-09-17 17:14:44.721 UTC [1] LOG:  database system is ready to accept connections
cache_1  | 1:C 17 Sep 2021 17:14:37.545 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
cache_1  | 1:C 17 Sep 2021 17:14:37.545 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
cache_1  | 1:C 17 Sep 2021 17:14:37.545 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
cache_1  | 1:M 17 Sep 2021 17:14:37.547 * monotonic clock: POSIX clock_gettime
cache_1  | 1:M 17 Sep 2021 17:14:37.570 * Running mode=standalone, port=6379.
cache_1  | 1:M 17 Sep 2021 17:14:37.571 # Server initialized
cache_1  | 1:M 17 Sep 2021 17:14:37.571 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
cache_1  | 1:M 17 Sep 2021 17:14:37.575 * Ready to accept connections
nginx_1  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx_1  | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx_1  | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx_1  | 2021/09/17 17:15:31 [emerg] 1#1: host not found in upstream "web" in /etc/nginx/conf.d/nginx.conf:2
nginx_1  | nginx: [emerg] host not found in upstream "web" in /etc/nginx/conf.d/nginx.conf:2
web_1    | standard_init_linux.go:228: exec user process caused: exec format error
wger-docker_nginx_1 exited with code 1
wger-docker_web_1 exited with code 1

It looks like the issue is probably here:
web_1 | standard_init_linux.go:228: exec user process caused: exec format error

Are there any known issues with using your wger/devel:latest image on a raspberry pi (aarch64)?

Removing Docker Antipattern

Hello,

Thanks for providing your app as a docker image! However, it's a bit of an anti-pattern to require manual shell commands on startup.

It would be more typical to run on container startup, with perhaps a flag set in an env var to enable or disable.

Would you be open to a PR which implements this? Something like:

ON_STARTUP_SYNC_EXERCISES=true

[Bug] Wger command "load-online-fictures" not working.

Version:
Latest

Description:
When executing the command wger load-online-fixtures within the container, the command seems to be run, but never finishes.
The console reports back
Downloading fixture data from https://github.com/wger-project/data/raw/master/fixtures/ingredients.json.zip...
but afterwards nothing happens.

To test it, I left it running overnight, but nothing changes.
Ingredients are also not added to the setup.

DJANGO_DEBUG=False not being honoured

My wger container has the DJANGO_DEBUG option set to False:

$ docker compose exec -T wgerweb env | grep DJANGO_DEBUG
DJANGO_DEBUG=False

But browsing to an invalid URL shows the Django debug page, including the text at the bottom:

You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

So it looks like this isn't being picked up by Django?

I can't quite tell which Dockerfile is being used to build the wger image on Docker Hub, so am unsure where to go to debug this. Is it the one in this directory?

Importing ingredients error | Fresh install of a Prod. instance

Summary:

docker-compose exec web wger load-online-fixtures Leads to Command: 'invoke load-online-fixtures' Exit code: -9

Recent Log msgs:

docker-compose exec web wger load-online-fixtures
*** No settings given, using /home/wger/src/settings.py
Downloading fixture data from https://github.com/wger-project/data/raw/master/fixtures/ingredients.json.zip...
-> fixture size: 5.03 MB
-> saving to temp file /tmp/tmpp4vq6u0i.json.zip
Traceback (most recent call last):
  File "/usr/local/bin/wger", line 33, in <module>
    sys.exit(load_entry_point('wger', 'console_scripts', 'wger')())
  File "/home/wger/src/wger/__main__.py", line 40, in main
    run(invoke_cmd + ' '.join(args), pty=True)
  File "/usr/local/lib/python3.9/dist-packages/invoke/__init__.py", line 48, in run
    return Context().run(command, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/invoke/context.py", line 95, in run
    return self._run(runner, command, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/invoke/context.py", line 102, in _run
    return runner.run(command, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/invoke/runners.py", line 380, in run
    return self._run_body(command, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/invoke/runners.py", line 442, in _run_body
    return self.make_promise() if self._asynchronous else self._finish()
  File "/usr/local/lib/python3.9/dist-packages/invoke/runners.py", line 509, in _finish
    raise UnexpectedExit(result)
invoke.exceptions.UnexpectedExit: Encountered a bad command exit code!

Command: 'invoke load-online-fixtures'

Exit code: -9

Stdout: already printed

Stderr: n/a (PTYs have no stderr)

Note:

Importing exercise images went well without any errors

Commands used;

docker-compose exec web python3 manage.py sync-exercises
docker-compose exec web python3 manage.py download-exercise-images

Deploy in RPi using MySQL or storing SQLite db

Hello people,
thanks for this amazing project.
I'm trying to deploy an instance of wger in RPi3 for myself but I cannot install PostgreSQL. So I want to know if it is possible to install it using my existing MYSQL DB or at least use the demo image but storing the SQLite DB in a volume.
Regarding the first option (use MYSQL) I didn't find any information of note in the documentation.
Regarding the second option (use the demo image) I tried to attach 3 volume to the container, in the following path:

  • /home/wger/db (settings the correct rw permissions)
  • /home/wger/media
  • /home/wger/static
    in order to store a local copy of the sqlite file and all the other static/media files, to achieve the persistence of date across any possible container restarts.

here is the compose-file:

version: "3.3"
services:
  wger:
    container_name: wger
    image: wger/demo:latest
    volumes:
      - /selfhosted_volume/wger/static/:/home/wger/static
      - /selfhosted_volume/wger/media/:/home/wger/media
      - /selfhosted_volume/wger/db/:/home/wger/db/
    ports:
       - 8000
    environment:
      - DJANGO_MEDIA_ROOT=/home/wger/media
      - ALLOW_REGISTRATION=True
      - ALLOW_GUEST_USERS=False
      - DJANGO_DEBUG=False

The container starts but when I try to access the webapp it give me the following exception:

Environment:


Request Method: GET
Request URL: http://wger.homenetwork.pi/en/software/features

Django Version: 3.2.11
Python Version: 3.9.5
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'django_extensions',
 'storages',
 'wger.config',
 'wger.core',
 'wger.mailer',
 'wger.exercises',
 'wger.gym',
 'wger.manager',
 'wger.nutrition',
 'wger.software',
 'wger.utils',
 'wger.weight',
 'wger.gallery',
 'wger.measurements',
 'captcha',
 'django.contrib.sitemaps',
 'easy_thumbnails',
 'compressor',
 'crispy_forms',
 'rest_framework',
 'rest_framework.authtoken',
 'django_filters',
 'django_bootstrap_breadcrumbs',
 'corsheaders')
Installed Middleware:
('corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'wger.utils.middleware.JavascriptAJAXRedirectionMiddleware',
 'wger.utils.middleware.WgerAuthenticationMiddleware',
 'wger.utils.middleware.RobotsExclusionMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.locale.LocaleMiddleware')



Traceback (most recent call last):
  File "/home/wger/src/wger/utils/language.py", line 54, in load_language
    language = Language.objects.get(short_name=used_language)
  File "/home/wger/venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/wger/venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(

During handling of the above exception (Language matching query does not exist.), another exception occurred:
  File "/home/wger/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/wger/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/wger/src/wger/software/views.py", line 37, in features
    return render(request, 'features.html', context)
  File "/home/wger/venv/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/wger/venv/lib/python3.9/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/home/wger/venv/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/wger/venv/lib/python3.9/site-packages/django/template/base.py", line 168, in render
    with context.bind_template(self):
  File "/usr/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/home/wger/venv/lib/python3.9/site-packages/django/template/context.py", line 244, in bind_template
    updates.update(processor(self.request))
  File "/home/wger/src/wger/utils/context_processor.py", line 28, in processor
    language = load_language()
  File "/home/wger/src/wger/utils/language.py", line 57, in load_language
    language = Language.objects.get(short_name="en")
  File "/home/wger/venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/wger/venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(

Exception Type: DoesNotExist at /en/software/features
Exception Value: Language matching query does not exist.

I'm almost sure this problem is caused by the fact that I'm mounting a local directory into the container to store the the sqlite db, because I noticed that if I try to remove the volume from db everything works well.
Do you have any suggestion on how I can fix this problem?
Thanks in advance

Missing linux/amd64 in wger/server:latest?

Hello.

My CI woke me up today with the following error when pulling the latest image for wger/server:

fatal: [instance]: FAILED! => {"changed": false, "msg": "Error pulling wger/server - code: None message: no matching manifest for linux/amd64 in the manifest list entries"}

and looks like the latest version is indeed only linux/arm64. Only 2.1-dev tag contains both arm64 and amd64.

Is this intentional? Only ARM now for latest?

Verification emails use localhost instead of SITE_URL

In prod.env, I have SITE_URL=https://wger.mydomain.tld. This is in a LAN-only environment with local reverse proxy.

I also have SMTP variables correctly setup:

ENABLE_EMAIL=True
EMAIL_HOST=smtp.mailgun.org
EMAIL_PORT=587
[email protected]
EMAIL_HOST_PASSWORD=mypassword
EMAIL_USE_TLS=True
EMAIL_USE_SSL=False

Verification emails are successfully sent, but the "click here" link uses localhost instead of SITE_URL:

http://localhost/email/email/long_email_verification_string

Replacing localhost with wger.mydomain.tld (SITE_URL) correctly loads the page and verifies the user.

Is this a bug, or have I missed a setting?

Exercises have no base

web_1 | Exercise 2b0205ef-40cc-49d3-b982-d42b60f05ebb has no base, this should not happen!Skipping...
web_1 | Exercise a9f2d62a-6a3c-4b20-b3ff-cb3654bf3195 has no base, this should not happen!Skipping...
web_1 | Exercise 9baf0689-e7d6-4809-9318-01a043860a82 has no base, this should not happen!Skipping...
web_1 | Exercise c81fa1a0-9bfe-474b-b78f-195ef791e499 has no base, this should not happen!Skipping...
web_1 | Exercise ebdd3ac2-dfa2-4c36-8c41-fbcbec16a042 has no base, this should not happen!Skipping...
web_1 | Exercise 9eb10e6a-97e1-46e1-b9ac-226bb25ca080 has no base, this should not happen!Skipping...
web_1 | Exercise ae308b2f-ceb2-4517-93b8-3b90f37fad47 has no base, this should not happen!Skipping...
web_1 | Exercise 87d5edb6-3ecf-4ff3-aa52-38a764e95120 has no base, this should not happen!Skipping...
web_1 | Exercise 2ac4a5f9-2b47-436e-843a-655580746aa3 has no base, this should not happen!Skipping...
web_1 | Exercise 1de6fe0a-f267-4509-84bc-2ecefbe5652d has no base, this should not happen!Skipping...
web_1 | Exercise 6f43fa49-d64e-4132-bebc-2fd722da6997 has no base, this should not happen!Skipping...
web_1 | Exercise d721e53c-afc2-4535-b0ff-61e158dd25f9 has no base, this should not happen!Skipping...
web_1 | Exercise 84794882-9d1d-480b-89ad-4861647b8f82 has no base, this should not happen!Skipping...

Just an FYI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.