diff --git a/.gitignore b/.gitignore index 5684672..5422a6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /venv/ /.idea/ +/static/ .env *.iml *.sqlite3 diff --git a/Dockerfile b/Dockerfile index 91c528d..4db03bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ RUN apt install -y curl # create user RUN useradd -ms /bin/bash bbct +RUN mkdir -p /bbct/static +RUN chown -R bbct /bbct USER bbct # install poetry diff --git a/bbct/settings.py b/bbct/settings.py index 6fe4094..4104c9c 100644 --- a/bbct/settings.py +++ b/bbct/settings.py @@ -137,4 +137,5 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ +STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' diff --git a/docker-compose.yml b/docker-compose.yml index 5e8bef0..9731ae6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,12 +10,18 @@ services: - db env_file: - .env + volumes: + - static_files:/bbct/static + nginx: build: ./nginx ports: - "8000:80" depends_on: - api + volumes: + - static_files:/static + db: image: postgres:13.0-alpine volumes: @@ -31,3 +37,4 @@ services: volumes: postgres_data: + static_files: diff --git a/entrypoint.sh b/entrypoint.sh index 3beeb55..608bf6d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,5 +12,6 @@ then fi poetry run python manage.py migrate +poetry run python manage.py collectstatic exec "$@" diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 836ed30..87d8e9b 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -6,6 +6,10 @@ server { listen 80; + location /static { + root /; + } + location / { proxy_pass http://bbct_api; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;