Skip to content

Commit

Permalink
Nginx for static files
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoest committed Jan 1, 2025
1 parent 68af815 commit e0318af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ RUN pip3 install -r requirements.txt

COPY . .

EXPOSE 8016
EXPOSE 80

RUN chmod +x ./init.sh
RUN chmod +x S1/initial_setup.sh

RUN apk add --no-cache nginx
COPY config/default.conf /etc/nginx/http.d/default.conf

CMD ["/bin/sh", "-c", "./init.sh"]
15 changes: 15 additions & 0 deletions config/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server {
listen 80 default_server;

location /static/ {
alias /opt/s1/S1/staticfiles/;
autoindex off;

expires 3M; # Cache for 3 months
add_header Cache-Control "public, max-age=31536000, immutable";
}

location / {
proxy_pass http://127.0.0.1:8016;
}
}
4 changes: 3 additions & 1 deletion init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
nginx -g "daemon on;"

crontab cron_schedule && crond
cd S1 && python manage.py collectstatic
cd S1 && gunicorn S1.wsgi --bind 0.0.0.0:8016
gunicorn S1.wsgi --bind 0.0.0.0:8016

0 comments on commit e0318af

Please sign in to comment.