Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I got it working #107

Open
deboy69 opened this issue Oct 28, 2024 · 5 comments
Open

How I got it working #107

deboy69 opened this issue Oct 28, 2024 · 5 comments

Comments

@deboy69
Copy link

deboy69 commented Oct 28, 2024

You maybe like me and stuggled for days to get this to work. There are so many little errors in this project that don't really get fixed. 1. permissions and 2. django set to false (causes it not to load properly). I used portainer which needs stack.env instead of prod.env to run. Adjust either way you use it.

Here is what I used to get this working. I dont use celery and I dont use the included Nginx, I use NPM. Once you get it up for the first time, chmod 777 -R /static and chmod 777 -R /media. Re run the container again. ssh into the container didnt work for me so I used portainer cmd. Hope this helps

once into the container run the following.
python3manage.py sync-exercies
  python3 manage.py download-exercise-images
  python3 manage.py download-exercise-videos/
  python3 manage.py sync-ingredients

Portainer stack or you can use compose.

services:
web:
image: wger/server:latest
env_file:
- stack.env
volumes:
- your local path/wger/static:/home/wger/static:rw
- your local path/wger/media:/home/wger/media:rw
environment:
- UMASK=022
- PUID=0
- PGID=0
ports:
- 8011:8000 #change 8011 if you have 8000 in use already
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8000
interval: 10s
timeout: 5s
start_period: 300s
retries: 5

db:
image: postgres:15-alpine
environment:
- POSTGRES_USER=wger
- POSTGRES_PASSWORD=wger
- POSTGRES_DB=wger
volumes:
- your local path/ wger/postgres-data:/var/lib/postgresql/data
expose:
- 5432
restart: unless-stopped
healthcheck:
test: pg_isready -U wger
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
########################################################
cache:
image: redis
expose:
- 6379
volumes:
-your local path/wger/redis-data:/data
restart: unless-stopped
healthcheck:
test: redis-cli ping
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
##########################################################

networks:
default:
name: wger_network

#############################################################################################

For NPM this goes in the advanced settings

location / {
proxy_pass http://ip address:port#
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_set_header X-Forwarded-Host $host:$server_port;
proxy_redirect off;
}

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

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

@deboy69
Copy link
Author

deboy69 commented Oct 28, 2024

Adjustment for NPM

For NPM this goes in the advanced settings

location / {
proxy_pass http://ip/ address:port#
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_set_header X-Forwarded-Host $host:$server_port;
proxy_redirect off;
}

location {location of your static folder}/static/ {
alias /wger/static/;
}

location {location of your media folder}/media/ {
alias /wger/media/;
}

@deboy69 deboy69 closed this as completed Oct 28, 2024
@deboy69 deboy69 reopened this Oct 28, 2024
@chrisbehectik
Copy link

chrisbehectik commented Jan 10, 2025

Can I ask what your .env file looks like? I have a very similiar setup also using NPM without celery and nginx but can't get it to work.

docker-compose.yml:

 services:
  fitness-app:
    container_name: fitness-app
    image: wger/server:latest
    depends_on:
      fitness-db:
        condition: service_healthy
      fitness-cache:
        condition: service_healthy
    env_file:
      - ./folder/.wger_env
    volumes:
      - ./folder/www:/home/wger/static
      - ./folder/media:/home/wger/media
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8000
      interval: 10s
      timeout: 5s
      start_period: 300s
      retries: 5
    restart: unless-stopped
    networks: 
      - fitness-net
      - nginx-proxy-manager

  fitness-db:
    container_name: fitness-db
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=wger
      - POSTGRES_PASSWORD=PASSWORD
      - POSTGRES_DB=NAME
    volumes:
      - ./folder/db:/var/lib/postgresql/data/
    healthcheck:
      test: pg_isready -U wger
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    restart: unless-stopped
    networks: 
      - fitness-net

  fitness-cache:
    container_name: fitness-cache
    image: redis
    volumes:
      - ./folder/cache:/data
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    restart: unless-stopped
    networks: 
      - fitness-net

networks:
  nginx-proxy-manager:
    external: true
  fitness-net:
    name: fitness-net
    driver: bridge

Custom Nginx Configuration:

location / {
proxy_pass http://fitness-app:8000
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_set_header X-Forwarded-Host $host:$server_port;
proxy_redirect off;
}

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

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

@rolandgeider
Copy link
Member

Note that using folders directly does cause problems (I have added a warning to the docs right now), if you get a set of steps to do so that everything works, I'll gladly add it to the readme

@deboy69
Copy link
Author

deboy69 commented Jan 14, 2025

Note that using folders directly does cause problems (I have added a warning to the docs right now), if you get a set of steps to do so that everything works, I'll gladly add it to the readme

What do you mean directly? Can you elaborate on that for clarification? Thanks

@rolandgeider
Copy link
Member

What do you mean directly? Can you elaborate on that for clarification? Thanks

@deboy69 sure, I mean mounting folders instead of using the volumes, so - ./folder/www:/home/wger/static vs - static:/wger/static:ro. Django collects static files from the application folder and copies them to static, which are then read and served by the web server and there are probably some user IDs mismatch (this could be fixed by running some chmod commands, but then you would need to do that every time something changes). Also this is only important for the static and media folders, cache, db etc should work fine without volumes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants