Skip to content

Commit

Permalink
Merge pull request #64 from BaseballCardTracker/35-static-files
Browse files Browse the repository at this point in the history
35 static files
  • Loading branch information
codeguru42 authored Sep 13, 2022
2 parents c137ee0 + 086f0e6 commit 959d135
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/venv/
/.idea/
/static/
.env
*.iml
*.sqlite3
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions bbct/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -31,3 +37,4 @@ services:

volumes:
postgres_data:
static_files:
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ then
fi

poetry run python manage.py migrate
poetry run python manage.py collectstatic

exec "$@"
4 changes: 4 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 959d135

Please sign in to comment.