Skip to content

Commit

Permalink
serve static (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyb committed Jan 10, 2023
1 parent eee5fc8 commit ccc9030
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
**/__pycache__
*.sqlite3
*env
staticfiles
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ dmypy.json
.pyre/

*.sqlite3
staticfiles
*env
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN pip install --no-cache-dir \
-r requirements.txt
ADD . /app
EXPOSE 8000
CMD python manage.py migrate && python manage.py runserver 0.0.0.0:8000
CMD /app/entrypoint.sh
3 changes: 3 additions & 0 deletions drf_passwordless_jwt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
Expand Down Expand Up @@ -100,6 +101,7 @@
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -185,6 +187,7 @@
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / "staticfiles"

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
Expand Down
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

python manage.py migrate
python manage.py collectstatic --noinput
python manage.py runserver 0.0.0.0:8000 &
wait -n
exit $?
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ djangorestframework
drfpasswordless-gstr169
PyJWT
django-cors-headers
whitenoise

0 comments on commit ccc9030

Please sign in to comment.