Skip to content

Instantly share code, notes, and snippets.

@alabeduarte
Last active December 29, 2016 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alabeduarte/869deb882c3dda26a038 to your computer and use it in GitHub Desktop.
Save alabeduarte/869deb882c3dda26a038 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
function _colored() { tput -Txterm setaf ${1}; echo -e ${2}; tput -Txterm sgr0; }
function log_error() { _colored 1 "${1}"; } # use for failures
function log_action() { _colored 3 "${1}"; } # use for warnings / attention
function log_command() { _colored "${1}"; } # use for debug messages
readonly MACHINE_NAME="dev"
readonly IS_OLDER_DOCKER=$(docker-machine -v | grep -c "0.3")
readonly HAS_MACHINE=$(docker-machine ls | grep -c $MACHINE_NAME)
readonly DEBUG=0
if [[ $DEBUG -ge 0 ]]; then
echo "HAS_MACHINE $HAS_MACHINE";
echo "MACHINE_NAME $MACHINE_NAME";
echo "IS_OLDER_DOCKER; $IS_OLDER_DOCKER"
fi
if [[ $IS_OLDER_DOCKER -ne 0 ]]; then
log_error "Error: Your docker-machine version is older; Please update your docker-machine to > 0.3"
exit
fi
if [ $HAS_MACHINE -eq 0 ]; then
log_action "Creating machine ..."
docker-machine create -d virtualbox $MACHINE_NAME
eval "$(docker-machine env $MACHINE_NAME)"
fi
log_action "Starting machine ..."
docker-machine start $MACHINE_NAME
eval "$(docker-machine env $MACHINE_NAME)"
if [[ ! -z $DOCKER_HOST ]]; then
log_action "Initializing docker ..."
docker-compose -f ./script/development/docker/docker-compose.yml up -d
fi
log_action 'Done!'
echo -e `docker-machine ls | grep $MACHINE_NAME`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment