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

Great repo. One question #14

Open
Cally99 opened this issue Nov 10, 2020 · 2 comments
Open

Great repo. One question #14

Cally99 opened this issue Nov 10, 2020 · 2 comments

Comments

@Cally99
Copy link

Cally99 commented Nov 10, 2020

I've just pulled this repo. I'm trying to get my own project running with a similar setup so when I run docker compose on and ec2 instance with daphne and gunicorn.
I was just wondering about static files. Does nginx serve static files from django?

I build the repo and got this error Traceback (most recent call last):
File "./manage.py", line 15, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/dist-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
collected = self.collect()
File "/usr/local/lib/python3.6/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/usr/local/lib/python3.6/dist-packages/django/contrib/staticfiles/finders.py", line 125, in list
for path in utils.get_files(storage, ignore_patterns):
File "/usr/local/lib/python3.6/dist-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
directories, files = storage.listdir(location)
File "/usr/local/lib/python3.6/dist-packages/django/core/files/storage.py", line 313, in listdir
for entry in os.listdir(path):
FileNotFoundError: [Errno 2] No such file or directory: '/app/backend/server/staticfiles'

@pplonski
Copy link
Owner

pplonski commented Nov 10, 2020

Static files are served with nginx, from docker-compose

    nginx:
        restart: always
        image: nginx:1.12-alpine
        ports:
            - 8000:8000
        volumes:
            - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
            - static_volume:/app/backend/server/django_static

The static_volume is pointing to /app/backend/server/django_static in django_static directory you should have your static files. You should set it in settings.py:

STATIC_ROOT = os.path.join(BASE_DIR, 'django_static')

@pplonski
Copy link
Owner

From your error I see that you have staticfiles as static dir. You should update docker-compose and it should (have to) work.

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

2 participants