Last active
April 6, 2020 15:48
-
-
Save landsman/514731b1cd94d379589a533a6b2d663f to your computer and use it in GitHub Desktop.
Pass variables for each docker-compose file - two environments
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/bash | |
echo "Starting fresh containers for DEVELOPMENT" | |
docker/variables.sh dev.env | |
docker-compose -f docker/dev/docker-compose.yml up --build --remove-orphans |
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/bash | |
echo "Building production..." | |
docker/variables.sh prod.env | |
# @todo: make tar file from build | |
docker-compose -f docker/prod/docker-compose.yml --build |
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/bash | |
set_variable () { | |
if [ ! -z "$1" ] && [[ ! $1 =~ ^#+ ]] | |
then | |
export $1 | |
fi | |
} | |
load_env_file (){ | |
if [ ! -f $1 ]; then | |
echo "File not found!" | |
exit 1 | |
fi | |
cat $1 | while read LINE; do | |
set_variable $LINE || true; | |
done | |
#echo "Passed $n variables from $1 file" | |
} | |
load_env_file $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker/compose#6170 (comment)