Skip to content

Commit

Permalink
Require a .env file for go.sh runtime.
Browse files Browse the repository at this point in the history
Now that Docker Compose can parse Bash compatible env files, we can share a common file between Docker and `go.sh` runtimes. This replaces `.env.local`, and behaves more consistently to production Docker runtimes where env vars may be set on the container, before `entrypoint.sh` runs.
  • Loading branch information
mrmachine committed Aug 4, 2020
1 parent 67ad3df commit 16bd390
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
10 changes: 10 additions & 0 deletions project_template/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# These variables are sourced by 'go.sh', used in 'docker-compose.yml', and passed
# through to the 'django' service via 'env_file'.

export COMPOSE_PROJECT_NAME='project_template-develop'
export DOTENV='develop'
export IMAGE_TAG='master'
export TRANSCRYPT_PASSWORD='' # Get from 1Password

# export SRC_PGDATABASE='initial_data.sql'
# export WITHOUT_COVERAGE=1
4 changes: 0 additions & 4 deletions project_template/.env.local.sample

This file was deleted.

1 change: 1 addition & 0 deletions project_template/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
# - elasticsearch
- postgres
- redis
env_file: .env
environment:
DOTENV: ${DOTENV:-develop}
# ELASTICSEARCH_ADDRESS: elasticsearch:9200
Expand Down
8 changes: 8 additions & 0 deletions project_template/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ if [[ "$CUR_PYTHON_VERSION" != "Python $REQ_PYTHON_VERSION" ]]; then
>&2 echo "ERROR: Missing Python version: $REQ_PYTHON_VERSION"
fi

if [[ ! -f .env ]]; then
MISSING=1
>&2 echo "ERROR: Missing '.env' file. Copy '.env.example' and update."
fi

# Abort if any dependencies are missing.
if [[ -n "${MISSING+1}" ]]; then
exit 1
fi

# Configure environment.
source .env

# Get absolute project directory from the location of this script.
# See: http://stackoverflow.com/a/4774063
export PROJECT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}"); pwd -P)
Expand Down

0 comments on commit 16bd390

Please sign in to comment.