diff --git a/python/Dockerfile b/python/Dockerfile index 336851f5..eacdf0df 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -11,4 +11,4 @@ RUN chmod +x add_data.sh && \ apt-get update && \ apt-get install -y eatmydata git git-lfs jq time #ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"] -CMD ./add_data.sh ${POSTGRES_USER} ${POSTGRES_PASS} ${POSTGRES_PORT} ${DB_NAME} ${POSTGRES_HOST} ${ES_ENDPOINT} ${ES_USER} ${ES_PASS} ${KIBANA_ENDPOINT} +CMD ./add_data.sh diff --git a/python/add_data.sh b/python/add_data.sh index 67f929a1..4d96efd0 100755 --- a/python/add_data.sh +++ b/python/add_data.sh @@ -11,16 +11,14 @@ trap : TERM INT set -e -POSTGRES_USER=$1 -POSTGRES_PASS=$2 -POSTGRES_PORT=$3 -DB_NAME=$4 -POSTGRES_HOST=$5 - -ES_ENDPOINT=$6 -ES_USER=$7 -ES_PASS=$8 -KIBANA_ENDPOINT=$9 +# Needed variables (defined in .env for Docker Compose, or in a Amazon ECS task definition) +ENV_VAR_LIST=( + POSTGRES_USER POSTGRES_PASS POSTGRES_PORT POSTGRES_HOST DB_NAME + POPULATE_DB \ + KIBANA_ENDPOINT ES_ENDPOINT ES_USER ES_PASS \ + loadDsraScenario loadPsraModels loadHazardThreat loadPhysicalExposure + loadRiskDynamics loadSocialFabric +) DSRA_REPOSITORY=https://github.com/OpenDRR/scenario-catalogue/tree/master/FINISHED @@ -314,6 +312,21 @@ merge_csv() { ####################### Begin main processes ####################### ############################################################################################ +LOG "# Begin main processes" + +LOG "## Check needed environment variables" + +for var in "${ENV_VAR_LIST[@]}"; do + INFO "$var = ${!var}" + if [[ -z ${!var} ]]; then + if [[ "$var" =~ ^(ES_USER|ES_PASS)$ ]]; then + INFO "$var is not set, but it is optional" + else + WARN "$var is mandatory but not set! Your build will likely fail!" + fi + fi +done + # Speed up file writes with eatmydata LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+"$LD_LIBRARY_PATH:"}/usr/lib/libeatmydata LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so diff --git a/sample.env b/sample.env index 6494f4a4..e7be8467 100644 --- a/sample.env +++ b/sample.env @@ -1,3 +1,5 @@ +# Sample .env file used by Docker Compose for python-opendrr service + POSTGRES_USER=postgres POSTGRES_PASS=password POSTGRES_PORT=5432 @@ -7,6 +9,7 @@ POPULATE_DB=0 KIBANA_ENDPOINT=http://kibana-opendrr:5601 ES_ENDPOINT=http://elasticsearch-opendrr:9200 +# ES_USER and ES_PASS are optional (can be empty) for local builds ES_USER= ES_PASS=