From 71ab6bc5504a5ee29147f1f7bcbc9b08af81c1e8 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Fri, 4 Dec 2020 15:55:11 +0100 Subject: [PATCH] Production fixes --- .gitignore | 2 +- app/Dockerfile | 4 ++-- app/bundesdata_app/settings.py | 4 ++-- app/django-entrypoint.sh | 3 ++- docker-compose.yml | 14 ++++++++++---- .env.tpl => live.env.tpl | 1 + nginx/nginx.conf | 2 +- 7 files changed, 19 insertions(+), 11 deletions(-) rename .env.tpl => live.env.tpl (95%) diff --git a/.gitignore b/.gitignore index af8c003..fe66ee4 100755 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,4 @@ static_volume !**/.gitkeep -.env \ No newline at end of file +live.env \ No newline at end of file diff --git a/app/Dockerfile b/app/Dockerfile index e94c279..b2471b3 100755 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -18,8 +18,8 @@ RUN pip install -r requirements.txt COPY . /usr/src/app/ # add wait for it -RUN git clone https://github.com/vishnubob/wait-for-it.git /wait-for-it -RUN chmod a+x /wait-for-it/wait-for-it.sh +RUN git clone https://github.com/vishnubob/wait-for-it.git +RUN chmod a+x wait-for-it/wait-for-it.sh # add entry point COPY ./django-entrypoint.sh django-entrypoint.sh diff --git a/app/bundesdata_app/settings.py b/app/bundesdata_app/settings.py index c288aa3..58e5f31 100755 --- a/app/bundesdata_app/settings.py +++ b/app/bundesdata_app/settings.py @@ -31,7 +31,7 @@ SESSION_COOKIE_SECURE = True # CHANGE the hosts according to your settings. -ALLOWED_HOSTS = ["127.0.0.1", "localhost", "192.168.0.14", "bundesdata.sporada.eu"] +ALLOWED_HOSTS = ["127.0.0.1", "localhost", "0.0.0.0", "bundesdata.sporada.eu"] # Application definition @@ -135,7 +135,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ -STATIC_URL = '/staticfiles/' +STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # WATSON diff --git a/app/django-entrypoint.sh b/app/django-entrypoint.sh index 682993f..fd8f1a6 100755 --- a/app/django-entrypoint.sh +++ b/app/django-entrypoint.sh @@ -2,4 +2,5 @@ python manage.py collectstatic --noinput python manage.py makemigrations --noinput python manage.py migrate --noinput -python manage.py runserver 0.0.0.0:8000 \ No newline at end of file + +exec "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 64174d9..fa399ee 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,17 +4,23 @@ services: web: build: ./app volumes: - - ./app/:/usr/src/app/ + - ./app/blog:/usr/src/app/blog + - ./app/bundesdata_app:/usr/src/app/bundesdata_app + - ./app/ngram_viewer:/usr/src/app/ngram_viewer + - ./app/speakers:/usr/src/app/speakers + - ./app/speeches:/usr/src/app/speeches - ./input_volume/:/usr/src/app/input_data - ./static_volume:/usr/src/app/staticfiles expose: - 8000 - env_file: .env + env_file: live.env depends_on: - db - command: ["./wait-for-it.sh", "db:5432", "--strict", "--timeout=0"] + command: > + bash -c "./wait-for-it/wait-for-it.sh db:5432 --strict --timeout=0 + && gunicorn --bind 0.0.0.0:8000 --workers=4 bundesdata_app.wsgi:application" db: - env_file: .env + env_file: live.env environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_USER: ${POSTGRES_USER} diff --git a/.env.tpl b/live.env.tpl similarity index 95% rename from .env.tpl rename to live.env.tpl index 4563339..bb43bcb 100644 --- a/.env.tpl +++ b/live.env.tpl @@ -2,6 +2,7 @@ ### Django settings ### SECRET_KEY=secretkey +DEBUG=False ### Postgress DB ### POSTGRES_PASSWORD=password diff --git a/nginx/nginx.conf b/nginx/nginx.conf index dbdb7ee..f04d97b 100755 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -13,7 +13,7 @@ server { proxy_redirect off; } - location /staticfiles/ { + location /static/ { alias /usr/src/app/staticfiles/; } }