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

Add support for docker compose secrets #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions 5/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
#!/bin/bash
set -e

# from the mysql 8.0 docker-entrypoint.sh, with minor modifications to fit ghost's patterns
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
local var="$1"
local fileVar="${var}_file"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo "Both $var and $fileVar are set (but are exclusive)"
return 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}

# Initialize values that might usefully be stored in a file
file_env 'database__connection__host'
file_env 'database__connection__user'
file_env 'database__connection__password'
file_env 'database__connection__database'
file_env 'mail__auth__user'
file_env 'mail__auth__pass'

# allow the container to be started with `--user`
if [[ "$*" == node*current/index.js* ]] && [ "$(id -u)" = '0' ]; then
find "$GHOST_CONTENT" \! -user node -exec chown node '{}' +
Expand Down
31 changes: 31 additions & 0 deletions 5/debian/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
#!/bin/bash
set -e

# from the mysql 8.0 docker-entrypoint.sh, with minor modifications to fit ghost's patterns
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
local var="$1"
local fileVar="${var}_file"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo "Both $var and $fileVar are set (but are exclusive)"
return 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}

# Initialize values that might usefully be stored in a file
file_env 'database__connection__host'
file_env 'database__connection__user'
file_env 'database__connection__password'
file_env 'database__connection__database'
file_env 'mail__auth__user'
file_env 'mail__auth__pass'

# allow the container to be started with `--user`
if [[ "$*" == node*current/index.js* ]] && [ "$(id -u)" = '0' ]; then
find "$GHOST_CONTENT" \! -user node -exec chown node '{}' +
Expand Down