Last active
December 29, 2016 12:58
-
-
Save alabeduarte/869deb882c3dda26a038 to your computer and use it in GitHub Desktop.
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
#!/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