From 39848e6df0635c1cdd837c25fa0d055bd22e54f2 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Tue, 1 Feb 2022 14:19:52 +0000 Subject: [PATCH] move environment variables to their own lines and set -eu this means that if the environment variable can't be set (for example, if you don't have aws-cli installed) then there's a suitable error message early on. --- scripts/run_with_docker.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/run_with_docker.sh b/scripts/run_with_docker.sh index e97adbfae..b423a7923 100755 --- a/scripts/run_with_docker.sh +++ b/scripts/run_with_docker.sh @@ -1,13 +1,19 @@ #!/bin/bash +set -eu + DOCKER_IMAGE_NAME=notifications-api source environment.sh +# this script should be run from within your virtualenv so you can access the aws cli +AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-"$(aws configure get aws_access_key_id)"} +AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-"$(aws configure get aws_secret_access_key)"} +: "${SQLALCHEMY_DATABASE_URI:=postgresql://postgres@host.docker.internal/notification_api}" + docker run -it --rm \ - -e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-$(aws configure get aws_access_key_id)} \ - -e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-$(aws configure get aws_secret_access_key)} \ - -e SQLALCHEMY_DATABASE_URI=${SQLALCHEMY_DATABASE_URI:-postgresql://postgres@host.docker.internal/notification_api} \ + -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ + -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ + -e SQLALCHEMY_DATABASE_URI=$SQLALCHEMY_DATABASE_URI \ -v $(pwd):/home/vcap/app \ - ${DOCKER_ARGS} \ ${DOCKER_IMAGE_NAME} \ ${@}