From f74e0ee034d35ab0b6a5eed3158705278ed2a71b Mon Sep 17 00:00:00 2001 From: Gregory Mundy Date: Tue, 11 Jun 2019 12:24:23 -0400 Subject: [PATCH 1/3] chore: add a sandbox environment configuration to ensure that the correct postgresql database string can be generated in production --- matching/config/config.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/matching/config/config.py b/matching/config/config.py index 8fd5515..2bb797c 100644 --- a/matching/config/config.py +++ b/matching/config/config.py @@ -28,6 +28,26 @@ def __init__(self): ) +class SandboxConfig(Config): + def __init__(self): + super().__init__() + os.environ['FLASK_ENV'] = 'production' + + DEBUG = False + + POSTGRES_USER = os.getenv('POSTGRES_USER','brighthive') + POSTGRES_PASSWORD = os.getenv('POSTGRES_PASSWORD', 'test_password') + POSTGRES_DATABASE = os.getenv('POSTGRES_DATABASE','mci_dev') + POSTGRES_PORT = os.getenv('POSTGRES_PORT', 5432) + POSTGRES_HOSTNAME = os.getenv('POSTGRES_HOSTNAME','localhost') + SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format( + POSTGRES_USER, + POSTGRES_PASSWORD, + POSTGRES_HOSTNAME, + POSTGRES_PORT, + POSTGRES_DATABASE + ) + class TestConfig(Config): def __init__(self): super().__init__() @@ -72,6 +92,8 @@ def get_config(config_type: str): return TestConfig() elif config_type.upper() == 'DEVELOPMENT': return DevelopmentConfig() + elif config_type.upper() == 'SANDBOX': + return SandboxConfig() @staticmethod def from_env(): From b84ed8ddd23e28bf1fa4c12625243ec1aed7f577 Mon Sep 17 00:00:00 2001 From: Gregory Mundy Date: Tue, 11 Jun 2019 12:42:25 -0400 Subject: [PATCH 2/3] chore: add ecr build script --- scripts/ecr_build.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scripts/ecr_build.sh diff --git a/scripts/ecr_build.sh b/scripts/ecr_build.sh new file mode 100755 index 0000000..b31718a --- /dev/null +++ b/scripts/ecr_build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# ecr_build.sh - Build the image and push it to Docker +# +# ---------------------------------------------------------------------------- + +CONTAINER_VERSION=1.0.0 +CONTAINER_NAME=brighthive/mci-matching-service +ECR_BASE=396527728813.dkr.ecr.us-east-2.amazonaws.com + +# Build the Container +docker build -t $CONTAINER_NAME:$CONTAINER_VERSION . +docker tag $CONTAINER_NAME:$CONTAINER_VERSION $CONTAINER_NAME:latest + +# Login to ECR +$(aws ecr get-login --no-include-email --region us-east-2) + +# Push to ECR +docker push $ECR_BASE/$CONTAINER_NAME:$CONTAINER_VERSION +docker push $ECR_BASE/$CONTAINER_NAME:latest \ No newline at end of file From aa68c1a5aa4f38d7f141aa341694073eaa6f0a6d Mon Sep 17 00:00:00 2001 From: Gregory Mundy Date: Tue, 11 Jun 2019 13:00:46 -0400 Subject: [PATCH 3/3] fix: update ecr build script --- scripts/ecr_build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/ecr_build.sh b/scripts/ecr_build.sh index b31718a..e436493 100755 --- a/scripts/ecr_build.sh +++ b/scripts/ecr_build.sh @@ -13,6 +13,10 @@ ECR_BASE=396527728813.dkr.ecr.us-east-2.amazonaws.com docker build -t $CONTAINER_NAME:$CONTAINER_VERSION . docker tag $CONTAINER_NAME:$CONTAINER_VERSION $CONTAINER_NAME:latest +# Tag the Containers +docker tag $CONTAINER_NAME:$CONTAINER_VERSION $ECR_BASE/$CONTAINER_NAME:$CONTAINER_VERSION +docker tag $CONTAINER_NAME:latest $ECR_BASE/$CONTAINER_NAME:latest + # Login to ECR $(aws ecr get-login --no-include-email --region us-east-2)