'Need help loading staticfiles with nginx and django to a container
I am having trouble loading the static files from my django project.
Here is a picture of my directories: direcctories
I have ran docker-compose up and I get the following errors: ERRORS
Here is what my nginx (default.conf) file looks like:
default.conf
http {
server {
listen 8080;
access_log /var/log/nginx/access.log
location / {
root /frontend/templates/frontend
# proxy_pass http://pathfinder_gunicorn;
# include /etc/nginx/mime.types;
}
location /static/ {
alias /static/;
}
location ~ \.(css)$ {
root /frontend/static/css;
}
}
}
Here is my Dockerfile:
FROM python:3.9-alpine
ENV PYTHONUNBUFFERED 1
WORKDIR /pathfinder
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
COPY ./entrypoint.sh /
ENTRYPOINT ["sh", "entrypoint.sh"]
RUN apk update
RUN apk add
RUN apk add npm
COPY ./frontend/package.json /frontend/package.json
COPY ./frontend/package-lock.json /frontend/package-lock.json
RUN cd frontend/ && npm install
RUN cd frontend/ && pwd
Here is my docker-compose.yml:
version: "3.8"
services:
pathfinder_gunicorn:
build:
context: .
volumes:
- static:/static
- ./frontend/static/:/frontend/static/
ports:
- "8080:8080"
image: pathfinder_gunicorn:v1
container_name: pathfinder_gunicorn
nginx:
build: ./nginx
volumes:
- static:/static
ports:
- "80:80"
depends_on:
- pathfinder_gunicorn
volumes:
static:
Here is the path to the directory from my docker-compose and Dockerfile:
./frontend/static/css The directory looks like: DIRECTORY
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
