Created
March 8, 2018 18:11
-
-
Save sanderson/7049a9912d31f291fcca03244bf02be8 to your computer and use it in GitHub Desktop.
Mapping Environment Variables with Nanobox
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
deploy.config: | |
transform: | |
- bash set-evars.sh |
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
#!/bin/sh | |
set -e | |
# Define a set_evar function that expects 2 arguments | |
# The first argument is the environment variable key | |
# The second argument is the environment variable value | |
# The value can be a literal string or a variable expansion | |
set_evar () { | |
echo $2 > /data/etc/env.d/$1 | |
echo ✓ $1 set | |
} | |
# Set environment vairables | |
set_evar "MY_DATABASE_HOST" "${DATA_DB_HOST}" | |
set_evar "MY_DATABASE_USER" "${DATA_DB_USER}" | |
set_evar "MY_DATABASE_PASS" "${DATA_DB_PASS}" | |
set_evar "MY_DATABASE_NAME" "gonano" | |
set_evar "MY_DATABASE_PORT" "3306" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment