-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for local secrets #227
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00db98b
Impl
KevinJBoyer be5f5b5
Add .gitignore
KevinJBoyer 870ed31
Move files and update docs
KevinJBoyer 709f536
Merge branch 'main' into kb/secrets-in-docker
KevinJBoyer 90c4ab4
Remove version from override example
KevinJBoyer 31a0c22
Update paths in compose files
KevinJBoyer 5703d6a
Fix mount dest
KevinJBoyer 937a6a7
Patch documentation
KevinJBoyer a145f07
Merge branch 'main' into kb/secrets-in-docker
KevinJBoyer f077472
Fake commit for CI
KevinJBoyer 2dd4a10
Undo fake commit for CI
KevinJBoyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
|
||
main-app: | ||
env_file: | ||
- local.env | ||
- .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,6 @@ A very simple [docker-compose.yml](/docker-compose.yml) has been included to sup | |
|
||
## Prerequisites | ||
|
||
**Note:** Run everything from within the `/app` folder: | ||
|
||
1. Install the version of Python specified in [.python-version](/app/.python-version) | ||
[pyenv](https://github.com/pyenv/pyenv#installation) is one popular option for installing Python, | ||
or [asdf](https://asdf-vm.com/). | ||
|
@@ -21,17 +19,25 @@ A very simple [docker-compose.yml](/docker-compose.yml) has been included to sup | |
|
||
3. If you are using an M1 mac, you will need to install postgres as well: `brew install postgresql` (The psycopg2-binary is built from source on M1 macs which requires the postgres executable to be present) | ||
|
||
4. You'll also need [Docker Desktop](https://www.docker.com/products/docker-desktop/) | ||
4. You'll also need [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed and running. | ||
|
||
## Run the application | ||
|
||
1. In your terminal, `cd` to the `app` directory of this repo. | ||
2. Make sure you have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed & running. | ||
3. Run `make setup-local` to install dependencies | ||
Comment on lines
-28
to
-30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed these lines:
|
||
4. Run `make init start` to build the image and start the container. | ||
5. Navigate to `localhost:8080/docs` to access the Swagger UI. | ||
6. Run `make run-logs` to see the logs of the running API container | ||
7. Run `make stop` when you are done to delete the container. | ||
**Note:** Run everything from within the `/app` folder: | ||
|
||
1. Run `make init start` to build the image and start the container. | ||
2. Navigate to `localhost:8080/docs` to access the Swagger UI. | ||
3. Run `make run-logs` to see the logs of the running API container | ||
4. Run `make stop` when you are done to stop the container. | ||
|
||
## (Optional) Configure local secrets | ||
|
||
If you need to pass secrets to the application via environment variables, copy the provided [/app/docker-compose.override.yml.example](/docker-compose.override.yml.example) to `/app/docker-compose.override.yml`. Then create an `/app/.env` file with your secrets. The override will pass this file to the Docker container with your application. | ||
|
||
```bash | ||
cp docker-compose.override.yml.example docker-compose.override.yml | ||
touch app/.env | ||
``` | ||
|
||
## Next steps | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Threading arbitrarily, - we might also need a change to the
load_local_env_vars
method which handles getting thelocal.env
file into your env vars when you run outside of docker. Right now that automatically gets called for unit tests in the conftest file:https://github.com/navapbc/template-application-flask/blob/main/app/tests/conftest.py#L21
I think if we just adjusted
load_local_env_vars
to do "if .env exists, load it before the local.env file" bit - then it would work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively - we could get rid of load_local_env_vars entirely and more accurately document how to do that properly when running outside of docker. Maybe I'll take that on next week.