Skip to content

Commit 7d4b4b5

Browse files
chris48sBethanyG
authored andcommitted
serve static assets from nginx
1 parent 1607b81 commit 7d4b4b5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docker-compose.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ services:
3030
container_name: app
3131
restart: on-failure
3232
command: >
33-
sh -c "python /opt/codebuddies/manage.py migrate &&
33+
sh -c "python /opt/codebuddies/manage.py collectstatic --clear --no-input &&
34+
python /opt/codebuddies/manage.py migrate &&
3435
uwsgi --ini /opt/codebuddies/uwsgi.ini"
3536
volumes:
3637
- ./project:/opt/codebuddies
@@ -51,6 +52,7 @@ services:
5152
- "8000:80"
5253
volumes:
5354
- ./nginx:/etc/nginx/conf.d
55+
- ./project/staticfiles/:/static
5456
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
5557
depends_on:
5658
- app

nginx/app.conf

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ server {
66
listen 80;
77
server_name localhost;
88

9+
location /static/ {
10+
alias /static/;
11+
}
12+
913
location / {
1014
proxy_pass http://app;
1115
proxy_set_header Host $http_host;

0 commit comments

Comments
 (0)