Skip to content

Commit

Permalink
Update packages & setup docker-compose to allow override.env file (#239)
Browse files Browse the repository at this point in the history
## Ticket

## Changes
Updated Python packages

Add support for an override.env file

## Context for reviewers
These python package updates mirror similar ones we've done already on
Simpler Grants.gov, so not concerned with any of them.

The override.env file uses something added to Docker in January 2024:
https://docs.docker.com/reference/compose-file/services/#required - in
short, you can specify multiple .env files and have some be optional.
This way we can always say to look for override.env, but not require it,
and allow a user to write whatever they want to it without checking it
in.

## Testing
Locally I was able to create override.env, it not be added to git, and
the overrides worked (changed `LOG_FORMAT` to `json` and back).

---------

Co-authored-by: Kevin Boyer <[email protected]>
  • Loading branch information
chouinar and KevinJBoyer authored Dec 11, 2024
1 parent 6775182 commit f715d8d
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 128 deletions.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ coverage.*
# Environment variables
.env
.envrc
override.env

# mypy
.mypy_cache
Expand Down
6 changes: 5 additions & 1 deletion app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ services:
- RUN_USER=${RUN_USER:-app}
command: ["poetry", "run", "flask", "--app", "src.app", "run", "--host", "0.0.0.0", "--port", "8080", "--reload"]
container_name: main-app
env_file: local.env
env_file:
- path: ./local.env
required: true
- path: ./override.env
required: false
ports:
- 8080:8080
volumes:
Expand Down
7 changes: 7 additions & 0 deletions app/local.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Local environment variables
# Used by docker-compose and it can be loaded
# by calling load_local_env_vars() from app/src/util/local.py
#
# To override values for your own personal local development
# create an override.env file in the same directory.
# Any environment variables defined in that file will
# take precedence over those defined here.
#
# See /docs/app/README.md for further details

ENVIRONMENT=local
PORT=8080
Expand Down
Loading

0 comments on commit f715d8d

Please sign in to comment.