Skip to content
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

Using secrets #80

Merged
merged 6 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions base/rootfs/etc/cont-init.d/00-load-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/with-contenv bash
set -e

# Read any secret files specified in environment variables.
echo "$(env | grep '=secret:')" | while read line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put instructions into the README? It looks like you have to do a specific thing with a filename to make this work, and we shouldn't assume people will go read the code to figure it out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And can you add your SECRETfile as a template to this repo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you scroll to "By .env technique" here you can see how to load a second .yml file by changing your COMPOSE_FILE declaration in your .env file https://stackoverflow.com/questions/55650342/import-docker-compose-file-in-another-compose-file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put example secret files in Islandora-Devops/isle-dc#123

do
# Skip empty lines
[[ -z $line ]] && continue

# Hack out the path to the secret.
environment_variable=$(echo $line | cut -d= -f1)
secret=$(echo $line | cut -d= -f2 | cut -d: -f2)

# Load the secret's value into the environment variable
if [ -f ${secret} ]; then
s6-env -i ${environment_variable}="$(cat ${secret})" s6-dumpenv -- /var/run/s6/container_environment
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ foreground {
FCREPO_DB_NAME="{{ getv "/db/name" "fcrepo" }}"
FCREPO_DB_PASSWORD="{{ getv "/db/password" "password" }}"
FCREPO_DB_PORT="{{ getv "/db/port" "3306" }}"
FCREPO_DB_ROOT_PASSWORD="{{ getv "/db/root/password" "passwod" }}"
FCREPO_DB_ROOT_PASSWORD="{{ getv "/db/root/password" "password" }}"
FCREPO_DB_ROOT_USER="{{ getv "/db/root/user" "root" }}"
FCREPO_DB_USER="{{ getv "/db/user" "fcrepo" }}"
FCREPO_PERSISTENCE_TYPE="{{ getv "/persistence/type" "file" }}"
Expand Down