Created
October 7, 2018 22:51
-
-
Save kevinvdburgt/fdb6eee1c53804ab5cb16f0b13e0cd38 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
#!/bin/bash | |
WORKSPACE=$1 | |
log() { | |
echo "[$(date +"%D %T")] $1" >> "$WORKSPACE/deployment.log" | |
echo $1 | |
} | |
# Check if the workspace directory exists | |
if [ ! -d "$WORKSPACE"]; then | |
echo "The directory $WORKSPACE doesnt exists." | |
exit 0 | |
fi | |
# Check if there is a docker-compose file, which we pull, down and put up again | |
if [ ! -f "$WORKSPACE/docker-compose.yml" ]; then | |
echo "The docker compose file at $WORKSPACE/docker-compose.yml doesnt exists" | |
exit 0 | |
fi | |
# Check if the GCR credentials file is there | |
if [ ! -f "$WORKSPACE/gcr.json" ]; then | |
echo "The GCR file is missint at $WORKSPACE/gcr.json" | |
exit 0 | |
fi | |
# Change directory into the workspace | |
cd $WORKSPACE | |
# Login on the docker registry | |
log "Authorize docker on https://eu.gcr.io/" | |
docker login -u _json_key -p "$(cat gcr.json)" https://eu.gcr.io/ | |
# Pull all the images | |
log "Pull/update all the new images from docker-compose.yml" | |
docker-compose pull | |
# Stop all the services | |
log "Stopping all services" | |
docker-compose down | |
# Start all services | |
log "Starting all services" | |
docker-compose up -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment