Skip to content

Commit

Permalink
Load dotenv file in CI/CD (#500)
Browse files Browse the repository at this point in the history
* Update bootstrap script to pull down dotenv
* Add bootstrap step to CI to load dotenv
* Improve logging of steps in cibuild
* Add format script for frontend app
* Update build context for Django service
* Update PR template to suggest running format script

Co-authored-by: Derek Dohler <[email protected]>
  • Loading branch information
aaronxsu and ddohler committed May 13, 2022
1 parent c2b2fd6 commit fc7b807
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Brief description of what this PR does, and why it is needed.


### Checklist

- [ ] Run `./scripts/format` to lint, format, and fix the application source code.

### Demo

Optional. Screenshots, `curl` examples, etc.
Expand Down
17 changes: 12 additions & 5 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ Pull down secrets from S3.
function pull_env() {
pushd "${DIR}"

if aws s3 cp "s3://${ECHOLOCATOR_SETTINGS_BUCKET}/.env" ".env"; then
echo "Updated environment variables file from ${ECHOLOCATOR_SETTINGS_BUCKET}"
elif [[ ! -f ".env" ]]; then
cp .env.sample .env
echo "Updated environment variables file from .env.sample"
# If there is already a dotenv file, do nothing
# If no such a file and no S3 config bucket configured, copy from local sample file
# If no such a file but has S3 config bucket configured, download from S3
if [[ ! -f ".env" ]]; then
if [ -z "${ECHOLOCATOR_SETTINGS_BUCKET}" ]; then
echo "No local .env file; No ECHOLOCATOR_SETTINGS_BUCKET env var supplied."
cp .env.sample .env
echo "Copied environment variables file from .env.sample to .env for local development."
echo "Please populate the fields in this file manually."
elif aws s3 cp "s3://${ECHOLOCATOR_SETTINGS_BUCKET}/.env" ".env"; then
echo "Updated environment variables file from ${ECHOLOCATOR_SETTINGS_BUCKET}"
fi
fi

popd
Expand Down
16 changes: 8 additions & 8 deletions scripts/update
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
if [ "${1:-}" = "--help" ]; then
usage
else
# Ensure container images are current
docker-compose build taui

# Separated to build taui static assets before copied to django container
# Build app container image first
docker-compose \
-f docker-compose.yml \
run --rm --no-deps --entrypoint "bash -c" taui \
"yarn install && yarn build"

docker-compose build database django
build app

# Install frontend NPM modules
docker-compose \
-f docker-compose.yml \
run --rm --no-deps app \
yarn install

# Build static asset bundle for React frontend
# Separated to build app static assets before copied to django container
docker-compose \
-f docker-compose.yml \
run --rm --no-deps app \
yarn run build

# Build django and db container images
docker-compose build database django

# Bring up PostgreSQL and Django in a way that respects
# configured service health checks.
docker-compose up -d database django
Expand Down
4 changes: 1 addition & 3 deletions src/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ COPY ./src/backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY ./src/backend /usr/local/src/backend

COPY ./taui/assets/ /usr/local/src/backend/static/assets
COPY ./taui/index.html /usr/local/src/backend/static/index.html
COPY ./src/frontend/build /usr/local/src/backend/static

CMD ["-b :8085", \
"--workers=2", \
Expand Down

0 comments on commit fc7b807

Please sign in to comment.