simple-tasks icon indicating copy to clipboard operation
simple-tasks copied to clipboard

Great repo. One question

Open Cally99 opened this issue 4 years ago • 2 comments

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'

Cally99 avatar Nov 10 '20 00:11 Cally99

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: https://github.com/pplonski/simple-tasks/blob/ae759a8100f6604b6d8fc00f19cf3aedbd945f3d/backend/server/server/settings.py#L154

pplonski avatar Nov 10 '20 09:11 pplonski

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

pplonski avatar Nov 10 '20 09:11 pplonski