Dockerfile créé avec mode production et mode développement
This commit is contained in:
parent
46f9fea2c2
commit
ab75a6120a
10
Dockerfile
10
Dockerfile
@ -8,9 +8,11 @@ COPY requirements.txt $APPS_DIR/
|
||||
|
||||
WORKDIR $APPS_DIR
|
||||
|
||||
# uWSGI requires linux-headers
|
||||
RUN set -ex \
|
||||
&& buildDeps=' \
|
||||
build-base \
|
||||
linux-headers \
|
||||
python3-dev \
|
||||
' \
|
||||
&& apk --no-cache --update add \
|
||||
@ -22,9 +24,13 @@ RUN set -ex \
|
||||
&& apk del $buildDeps \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
COPY ./collection $APPS_DIR
|
||||
COPY ./collection .
|
||||
|
||||
VOLUME $DB_DIR
|
||||
|
||||
COPY ./docker-entrypoint.sh .
|
||||
COPY ./uwsgi.ini .
|
||||
ENTRYPOINT ["./docker-entrypoint.sh"]
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["/bin/sh"]
|
||||
CMD ["prod"]
|
||||
|
1
TODO
1
TODO
@ -4,7 +4,6 @@
|
||||
* Tests sur Console
|
||||
* Tests sur Game
|
||||
* Données initiales des consoles connues
|
||||
* Dockerfile avec UWSGI
|
||||
* API django rest framework
|
||||
* documentation API
|
||||
* travis.yml to launch test
|
||||
|
18
collection/collection/production.py
Normal file
18
collection/collection/production.py
Normal file
@ -0,0 +1,18 @@
|
||||
"""
|
||||
Django production settings
|
||||
"""
|
||||
import os
|
||||
from collection.settings import * # NOQA
|
||||
|
||||
DEBUG = os.getenv('DEBUG', False)
|
||||
|
||||
SECRET_KEY = os.getenv('SECRET_KEY')
|
||||
|
||||
ALLOWED_HOSTS = [os.getenv('ALLOWED_HOSTS', '*')]
|
||||
|
||||
# Domain configuration:
|
||||
# - if you have a specific domain to secure, change ALLOWED_HOSTS like this:
|
||||
# ALLOWED_HOSTS = ['domain.tld', 'domain.tld.']
|
||||
# - if you use a proxy like Nginx, you need to add this line into config:
|
||||
# `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;`
|
||||
USE_X_FORWARDED_HOST = True
|
@ -111,12 +111,15 @@ TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
USE_L10N = False
|
||||
|
||||
USE_TZ = True
|
||||
USE_TZ = False
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(os.path.abspath(os.path.curdir), 'static')
|
||||
if not os.getenv('STATIC_ROOT', None):
|
||||
STATIC_ROOT = os.path.abspath(os.getenv('STATIC_ROOT'))
|
||||
|
17
docker-entrypoint.sh
Executable file
17
docker-entrypoint.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
# Make database writable
|
||||
chown -R guest "$DB_DIR"
|
||||
|
||||
if [ "$1" = 'dev' ]; then
|
||||
export DJANGO_SETTINGS_MODULE=collection.settings
|
||||
exec python3 manage.py runserver 0.0.0.0:8000
|
||||
elif [ "$1" = 'prod' ]; then
|
||||
export DJANGO_SETTINGS_MODULE=collection.production
|
||||
# Collect static files
|
||||
python3 manage.py collectstatic --noinput --clear -v 0
|
||||
exec uwsgi --ini uwsgi.ini --pythonpath "$APPS_DIR" --static-map=/static/="$STATIC_ROOT"
|
||||
fi
|
||||
|
||||
exec "$@"
|
@ -1,2 +1,3 @@
|
||||
Django==1.11
|
||||
PyYAML==3.12
|
||||
uWSGI==2.0.15
|
||||
|
Loading…
Reference in New Issue
Block a user