Skip to content

Instantly share code, notes, and snippets.

@landsman
Last active April 6, 2020 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landsman/514731b1cd94d379589a533a6b2d663f to your computer and use it in GitHub Desktop.
Save landsman/514731b1cd94d379589a533a6b2d663f to your computer and use it in GitHub Desktop.
Pass variables for each docker-compose file - two environments
#!/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
#!/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
#!/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
@landsman
Copy link
Author

landsman commented Feb 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment