Skip to content

Commit

Permalink
Merge pull request #208 from CogStack/use-envs
Browse files Browse the repository at this point in the history
Use envs
  • Loading branch information
tomolopolis authored Sep 25, 2024
2 parents ce04429 + 0f3a437 commit 358fe78
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ services:
- api-static:/home/api/static
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites-enabled/:/etc/nginx/sites-enabled
env_file:
- ./envs/env
ports:
- ${MCTRAINER_PORT:-8001}:8000
depends_on:
Expand All @@ -41,6 +43,8 @@ services:
container_name: mct_solr
image: solr:8
restart: always
env_file:
- ./envs/env
ports:
- ${SOLR_PORT:-8983}:8983
volumes:
Expand Down
6 changes: 5 additions & 1 deletion docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- api-db:/home/api/db
- api-db-backup:/home/api/db-backup
env_file:
- ./envs/env
- ./envs/env-prod
entrypoint: /home/scripts/entry.sh
command: cron -f -l 2

Expand All @@ -44,6 +44,8 @@ services:
- api-static:/home/api/static
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites-enabled/:/etc/nginx/sites-enabled
env_file:
- ./envs/env-prod
ports:
- "${MCTRAINER_PORT:-8001}:8000"
depends_on:
Expand All @@ -54,6 +56,8 @@ services:
container_name: mct_solr
image: solr:8
restart: always
env_file:
- ./envs/env-prod
expose:
- "8983"
volumes:
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ services:
- api-static:/home/api/static
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites-enabled/:/etc/nginx/sites-enabled
env_file:
- ./envs/env
ports:
- ${MCTRAINER_PORT:-8001}:8000
depends_on:
Expand All @@ -50,6 +52,8 @@ services:
container_name: mct_solr
image: solr:8
restart: always
env_file:
- ./envs/env
ports:
- ${SOLR_PORT:-8983}:8983
volumes:
Expand Down
6 changes: 3 additions & 3 deletions envs/env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV=non-prod
CSRF_TRUSTED_ORIGINS=

### Django debug setting - to live-reload etc. ###
DEBUG=True
DEBUG=1

### Load example CDB, Vocab ###
LOAD_EXAMPLES=1
Expand All @@ -32,7 +32,7 @@ DB_PATH=${DB_DIR}/db.sqlite3
DB_BACKUP_DIR=/home/api/db-backup

# Resubmit all on startup
RESUBMIT_ALL_ON_STARTUP=1
RESUBMIT_ALL_ON_STARTUP=0

# Front end env vars
LOAD_NUM_DOC_PAGES=10
Expand All @@ -41,4 +41,4 @@ LOAD_NUM_DOC_PAGES=10
[email protected]
EMAIL_PASS="to be changed"
EMAIL_HOST=mail.cogstack.org
EMAIL_PORT=465
EMAIL_PORT=465
2 changes: 1 addition & 1 deletion envs/env-prod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENV=prod
CSRF_TRUSTED_ORIGINS=

# Django Debug mode should be False for prod
DEBUG=False
DEBUG=0

### Load example CDB, Vocab ###
LOAD_EXAMPLES=0
Expand Down
10 changes: 7 additions & 3 deletions webapp/api/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@
SECRET_KEY = 'q$&esydgbn2=#-k5s5i(+^dtxs1@$50_(ln0wuw@zig4m&^m7='

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', True)
if realm == 'prod' and DEBUG:
log.warning('Running in prod realm with DEBUG=True, are you sure you want to do that?')
try:
DEBUG = bool(int(os.environ.get('DEBUG', 1)))
if realm == 'prod' and DEBUG:
log.warning('Running in prod realm with DEBUG=True, are you sure you want to do that?')
except ValueError as e:
log.error('Error parsing DEBUG env, setting DEBUG to True. DEBUG env var should be set to 0 (false) or 1 (true).')
DEBUG = True

ALLOWED_HOSTS = ['*']

Expand Down

0 comments on commit 358fe78

Please sign in to comment.