Skip to content

Commit bd81efa

Browse files
authored
Env (#544)
* additional ebextensions for variables * debug * debug * debug * debug * debug * debug
1 parent 3775dff commit bd81efa

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ docker-db-populate:
1919

2020
docker-test:
2121
docker-compose exec web coverage run manage.py test --exclude=selenium
22-
22+
23+
docker-score:
24+
docker-compose exec web ./manage.py crontab_scoring
25+
2326
docker-create-db:
2427
docker-compose exec -it db bash
2528
psql -U postgres

webcdi/.ebextensions/02_initial.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ container_commands:
1111
04_create_log_dir_change_permissions:
1212
command: "mkdir -p /var/log/app && chmod g+s /var/log/app"
1313
05a_create_log_file_change_permissions:
14-
command: "touch /var/log/app/django.log && chmod 664 /var/log/app/django.log"
14+
command: "touch /var/log/app/django.log && chmod 666 /var/log/app/django.log"
1515
05b_create_log_file_change_permissions:
16-
command: "touch /var/log/app/django_error.log && chmod 664 /var/log/app/django_error.log"
16+
command: "touch /var/log/app/django_error.log && chmod 666 /var/log/app/django_error.log"
1717
07_log_dir_change_owner:
1818
command: "chown -R root:webapp /var/log/app"
1919

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
commands:
2+
setvars:
3+
command: /opt/elasticbeanstalk/bin/get-config environment | jq -r 'to_entries | .[] | "export \(.key)=\"\(.value)\""' > /etc/profile.d/local.sh
4+
packages:
5+
yum:
6+
jq: []

webcdi/webcdi/settings.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ def get_secret(secret_name, region_name="us-west-2"):
4646
AWS_STORAGE_BUCKET_NAME = os.environ["AWS_STORAGE_BUCKET_NAME"]
4747
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
4848

49-
ALLOWED_HOSTS = json.loads(os.environ["ALLOWED_HOSTS"])
49+
50+
def json_or_string_to_list(var):
51+
try:
52+
return json.loads(var)
53+
except Exception as e:
54+
return var.replace('[','').replace(']','').split(',')
55+
56+
57+
ALLOWED_HOSTS = json_or_string_to_list(os.environ["ALLOWED_HOSTS"])
5058
if AWS_INSTANCE:
5159
ALLOWED_HOSTS += [
5260
"ec2-52-88-52-34.us-west-2.compute.amazonaws.com",
@@ -66,7 +74,7 @@ def get_secret(secret_name, region_name="us-west-2"):
6674
for IP in list(NEW_IPS):
6775
ALLOWED_HOSTS.append(IP)
6876

69-
ADMINS = json.loads(os.environ["ADMINS"])
77+
ADMINS = json_or_string_to_list(os.environ["ADMINS"])
7078

7179
DJANGO_SERVER_TYPE = os.environ.get("DJANGO_SERVER_TYPE", "DEV") # DEV or PROD
7280

0 commit comments

Comments
 (0)