Portainer Templates logo

Portainer Templates

Wger Wger

Stack

Fitness

Self hosted FLOSS fitness/workout, nutrition and weight tracker written with Django

Configuration

Type
Compose
Platform
linux
Source

Template by xneo1·Source

Services

wger-web

Configuration

Image
wger/server:latest
Ports
8000
Volumes
/home/wger/static : /portainer/Files/AppData/Config/wger/static/home/wger/media : /portainer/Files/AppData/Config/wger/media
Env vars
SECRET_KEY=wger-docker-supersecret-key-1234567890!@#$%^&*(-_)SIGNING_KEY=wger-docker-secret-jwtkey-1234567890!@#$%^&*(-_=+FROM_EMAIL=info@example.comTIME_ZONE=Europe/AthensALLOW_REGISTRATION=TrueALLOW_GUEST_USERS=TrueALLOW_UPLOAD_VIDEOS=TruMIN_ACCOUNT_AGE_TO_TRUST=21SYNC_EXERCISES_ON_STARTUP=FalseDOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=FalseDJANGO_DB_ENGINE=django.db.backends.postgresqlDJANGO_DB_DATABASE=wgerDJANGO_DB_USER=wgerDJANGO_DB_PASSWORD=wgerDJANGO_DB_HOST=dbDJANGO_DB_PORT=5432DJANGO_PERFORM_MIGRATIONS=TrueDJANGO_CACHE_BACKEND=django_redis.cache.RedisCacheDJANGO_CACHE_LOCATION=redis://cache:6379/1DJANGO_CACHE_TIMEOUT=12DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClientAXES_ENABLED=TrueAXES_FAILURE_LIMIT=10AXES_COOLOFF_TIME=30AXES_HANDLER=axes.handlers.cache.AxesCacheHandlerDJANGO_DEBUG=FalseWGER_USE_GUNICORN=TrueEXERCISE_CACHE_TTL=10SITE_URL=http://localhostACCESS_TOKEN_LIFETIME=10REFRESH_TOKEN_LIFETIME=24
Restart
unless-stopped

Image details

Pulls: 2.6M
User: rolandgeider
Created: Oct 10, 2021
Updated: 9 hours ago
Status: active

wger-nginx

Configuration

Image
nginx:stable
Ports
680:80
Volumes
/etc/nginx/conf.d/default.conf : /portainer/Files/AppData/Config/wger/nginx.conf/wger/static : /portainer/Files/AppData/Config/wger/static/wger/media : /portainer/Files/AppData/Config/wger/media
Restart
unless-stopped

Image details

Pulls: 13.3B
User: stackbrew
Created: Jun 05, 2014
Updated: 4 days ago
Status: active

wger-db

Configuration

Image
postgres:12-alpine
Volumes
/var/lib/postgresql/data/ : /portainer/Files/AppData/Config/wger/postgres-data
Env vars
POSTGRES_USER=wgerPOSTGRES_PASSWORD=wgerPOSTGRES_DB=wger
Restart
unless-stopped

Image details

Pulls: 11.2B
User: stackbrew
Created: Jun 05, 2014
Updated: 1 hour ago
Status: active

wger-cache

Configuration

Image
redis
Restart
unless-stopped

Image details

Pulls: 11.1B
User: stackbrew
Created: Jun 05, 2014
Updated: 9 days ago
Status: active

Standalone Install

Select an install method, to see config/commands for deploying Wger

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select Wger, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo
Original stackfile

The compose file this template deploys, straight from its repo:

services:
  wger-web:
    image: wger/server:latest
    container_name: wger_server
    depends_on:
      wger-db:
        condition: service_healthy
      wger-cache:
        condition: service_healthy
    environment:
      - SECRET_KEY=wger-docker-supersecret-key-1234567890!@#$%^&*(-_)
      - SIGNING_KEY=wger-docker-secret-jwtkey-1234567890!@#$%^&*(-_=+
      - FROM_EMAIL=info@example.com
      - TIME_ZONE=Europe/Athens
      # Application
      - ALLOW_REGISTRATION=True
      - ALLOW_GUEST_USERS=True
      - ALLOW_UPLOAD_VIDEOS=Tru
      # 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
    volumes:
      - /portainer/Files/AppData/Config/wger/static:/home/wger/static
      - /portainer/Files/AppData/Config/wger/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

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

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

  wger-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

Or deploy it directly from the source:

git clone https://github.com/xneo1/portainer_templates
cd portainer_templates
docker compose -f Template/Stack/wger.yml up -d

More install options in our documentation.

Container Documentation

wger-web Documentation

Server for a wger installation

wger-nginx Documentation

Official build of Nginx.

wger-db Documentation

The PostgreSQL object-relational database system provides reliability and data integrity.

wger-cache Documentation

Redis is the world’s fastest data platform for caching, vector search, and NoSQL databases.

Serve Wger on your own domain behind Caddy, Nginx or Traefik. Fill in your domain and copy the result. It's a starting point, some apps need their own base URL or extra headers set too.

Proxying wger.example.com to http://wger-web:8000

Add this to your Caddyfile

wger.example.com {
	reverse_proxy http://wger-web:8000
}

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Port already in use

If deployment fails with "Bind for 0.0.0.0:680 failed: port is already allocated", something else on your server is using that port.

  • Find what's using it: sudo ss -tlnp | grep :680
  • Stop the other service, or pick a different host port. In 680:80 only the left number is yours to change, the right one belongs to the app.

Published on a random port

This template exposes 8000 without setting a host port, so Docker picks a random free one on every deploy.

  • Find it in the Ports column of Portainer's container list, or with docker port <container>

Running but the page won't load

The container is up but nothing appears in your browser.

  • Use your server's real IP: http://your-server-ip:680. The 0.0.0.0 link Portainer shows isn't a real address.
  • Give it a minute after first deploy, wger can take a while to initialise.
  • Make sure your firewall allows the port, e.g. sudo ufw allow 680

Permission denied on volumes

If the logs show "permission denied", the app can't write to its data folder on the host.

  • Fix the ownership: sudo chown -R 1000:1000 /portainer/Files/AppData/Config/wger/static (and the same for the other mapped folders)

Image won't pull

Test the pull directly on the host: docker pull wger/server:latest

  • "manifest unknown" means the tag no longer exists. This template uses latest, so try pinning a specific version instead.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect <container> --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Stack won't deploy

Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.

  • YAML only accepts spaces for indentation, a single tab breaks the whole file.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A Compose stack

Wger is a Compose stack, a set of containers (4 of them) defined in one file and brought up together by Portainer, then started and stopped as a single app.

The services

This stack is built from 4 containers that run side by side. Here's each one, with the image it runs and anything it waits for first:

  • wger-web runs wger/server:latest, starts after wger-db, wger-cache
  • wger-nginx runs nginx:stable, starts after wger-web
  • wger-db runs postgres:12-alpine
  • wger-cache runs redis

Ports

A port is the door the app answers on. A mapping like 680:80 means it's reachable on port 680 of your server, where the left number is yours to change and the right one belongs to the app. Once it's running, open http://your-server-ip:680 in a browser. It opens:

  • 8000, published on a random host port
  • 680:80, likely the web interface

Volumes

A volume is where Wger keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /home/wger/static from /portainer/Files/AppData/Config/wger/static on the host
  • /home/wger/media from /portainer/Files/AppData/Config/wger/media on the host
  • /etc/nginx/conf.d/default.conf from /portainer/Files/AppData/Config/wger/nginx.conf on the host
  • /wger/static from /portainer/Files/AppData/Config/wger/static on the host
  • /wger/media from /portainer/Files/AppData/Config/wger/media on the host
  • /var/lib/postgresql/data/ from /portainer/Files/AppData/Config/wger/postgres-data on the host

Environment variables

Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Wger takes 34 of them, all with defaults you can leave alone or tweak:

  • SECRET_KEY, defaults to wger-docker-supersecret-key-1234567890!@#$%^&*(-_)
  • SIGNING_KEY, defaults to wger-docker-secret-jwtkey-1234567890!@#$%^&*(-_=+
  • FROM_EMAIL, defaults to info@example.com
  • TIME_ZONE, defaults to Europe/Athens
  • ALLOW_REGISTRATION, defaults to True
  • ALLOW_GUEST_USERS, defaults to True
  • ALLOW_UPLOAD_VIDEOS, defaults to Tru
  • MIN_ACCOUNT_AGE_TO_TRUST, defaults to 21
  • SYNC_EXERCISES_ON_STARTUP, defaults to False
  • DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP, defaults to False
  • DJANGO_DB_ENGINE, defaults to django.db.backends.postgresql
  • DJANGO_DB_DATABASE, defaults to wger
  • DJANGO_DB_USER, defaults to wger
  • DJANGO_DB_PASSWORD, defaults to wger
  • DJANGO_DB_HOST, defaults to db
  • DJANGO_DB_PORT, defaults to 5432
  • DJANGO_PERFORM_MIGRATIONS, defaults to True
  • DJANGO_CACHE_BACKEND, defaults to django_redis.cache.RedisCache
  • DJANGO_CACHE_LOCATION, defaults to redis://cache:6379/1
  • DJANGO_CACHE_TIMEOUT, defaults to 12
  • DJANGO_CACHE_CLIENT_CLASS, defaults to django_redis.client.DefaultClient
  • AXES_ENABLED, defaults to True
  • AXES_FAILURE_LIMIT, defaults to 10
  • AXES_COOLOFF_TIME, defaults to 30
  • AXES_HANDLER, defaults to axes.handlers.cache.AxesCacheHandler
  • DJANGO_DEBUG, defaults to False
  • WGER_USE_GUNICORN, defaults to True
  • EXERCISE_CACHE_TTL, defaults to 10
  • SITE_URL, defaults to http://localhost
  • ACCESS_TOKEN_LIFETIME, defaults to 10
  • REFRESH_TOKEN_LIFETIME, defaults to 24
  • POSTGRES_USER, defaults to wger
  • POSTGRES_PASSWORD, defaults to wger
  • POSTGRES_DB, defaults to wger

Restart policy

The restart policy here is unless-stopped, so Docker restarts Wger after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).

Networking

Portainer puts these services on one shared private network, so they can find each other by name (like wger-web) while only the ports above are open to you.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Wger up. Add the template list to Portainer once, then deploying Wger is a click rather than a wall of config.