I am playing with a docker project. Django+gunicorn in one container, nginx in another container.
When I switched over from the Django dev server to gunicorn, I noticed that all my static files weren't being served. I've been trying to troubleshoot this for days thinking it was an nginx issue, but if I visit the container of Django/gunicorn (and not nginx), I also don't see static files showing up here, so this makes me think it is not an nginx issue but just a simple error in my Django settings?
Django settings.py
DEBUG = False
STATIC_ROOT = os.path.join(PACKAGE_ROOT, "static1")
STATIC_URL = "/static/"
STATICFILES_DIRS = [
os.path.join(PACKAGE_ROOT, "static"),
]
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
nginx
server {
listen 80;
server_name example.org;
charset utf-8;
location /static {
alias /root/proj/proj/static;
}
}
Note: I set this alias to /root/proj/proj/static, because this is the directory path to where static files are actually located inside the Django/gunicorn container... Am I correct in setting the alias to this path?
docker-compose
parentserver:
build: ./parentserver
expose:
- "8000"
links:
- postgres:postgres
- authserver:authserver
volumes:
- /usr/src/app
- /usr/src/app/static
env_file: .env
environment:
DEBUG: 'true'
command: ./startup.sh
nginx:
build: ./nginx/
ports:
- "80:80"
volumes:
- /www/static
volumes_from:
- parentserver
links:
- parentserver:parentserver
Are my volumes set wrong?
Would appreciate any feedback suggestions.