-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove secrets from docker-compose.override.yml
This commit removes secrets from docker-compose.override.yml in favour of storing these in 1Password and pulling them in at runtime via the use of a .env file. It includes a modified version of the script created by @Mhowell494 to make the .env file available at the time of running the app and to ensure that it is cleaned up after the app has exited.
- Loading branch information
1 parent
53cd030
commit 98e2121
Showing
4 changed files
with
60 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ out/ | |
.env | ||
gradle.properties | ||
pgdata/ | ||
|
||
# Local environment variables for testing | ||
*.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
Binary file not shown.
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,33 @@ | ||
#!/bin/bash | ||
|
||
# Ensure the script stops if any command fails | ||
set -euo pipefail | ||
|
||
# Specify the vault and the document name in 1Password | ||
VAULT="LAA Crime Apps" | ||
DOCUMENT="EnvironmentVariables-EvidenceService-App" | ||
APP_ENV_FILE="./app.env" | ||
|
||
function remove_env_file() | ||
{ | ||
echo "Removing .env file" | ||
rm -f "$APP_ENV_FILE" | ||
} | ||
|
||
trap remove_env_file EXIT | ||
|
||
echo "Signing into 1Password..." | ||
eval $(op signin --account ministryofjustice) | ||
|
||
echo "Fetching latest .env file from 1Password..." | ||
op document get "$DOCUMENT" --vault "$VAULT" --output "$APP_ENV_FILE" --force | ||
|
||
if [ ! -f "$APP_ENV_FILE" ]; then | ||
echo "Failed to retrieve .env file from 1Password." | ||
exit 1 | ||
fi | ||
|
||
echo ".env file successfully retrieved." | ||
|
||
echo "Starting Docker containers..." | ||
docker-compose up --build |