From 126387becc69cc9814800561490d8ad26ba2d113 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 30 Mar 2017 11:37:18 -0600 Subject: [PATCH] Adjusted docker build script --- circle.yml | 4 ++-- scripts/{deploy.sh => docker.sh} | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) rename scripts/{deploy.sh => docker.sh} (78%) diff --git a/circle.yml b/circle.yml index 2357ecf4c..c97f30cee 100644 --- a/circle.yml +++ b/circle.yml @@ -47,9 +47,9 @@ deployment: release: tag: /v[0-9]+(\.[0-9]+)*/ commands: - - bash ./scripts/deploy.sh + - bash ./scripts/docker.sh deploy latest: branch: master commands: - - bash ./scripts/deploy.sh + - bash ./scripts/docker.sh deploy diff --git a/scripts/deploy.sh b/scripts/docker.sh similarity index 78% rename from scripts/deploy.sh rename to scripts/docker.sh index efb182dc9..4aef5956f 100644 --- a/scripts/deploy.sh +++ b/scripts/docker.sh @@ -2,9 +2,7 @@ set -e -docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - -# Sourced from https://segment.com/blog/ci-at-segment/ +# Inspired by https://segment.com/blog/ci-at-segment/ deploy_tag() { # Find our individual versions from the tags @@ -50,10 +48,21 @@ deploy_latest() { docker build -t coralproject/talk:latest -f Dockerfile . docker build -t coralproject/talk:latest-onbuild -f Dockerfile.onbuild . -# deploy based on the env -if [ -n "$CIRCLE_TAG" ] +if [ "$1" -eq "deploy" ] then - deploy_tag -else - deploy_latest -fi + + if [[ -n "$DOCKER_EMAIL" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] + then + + # Log the Docker Daemon in + docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS + fi + + # deploy based on the env + if [ -n "$CIRCLE_TAG" ] + then + deploy_tag + else + deploy_latest + fi +fi \ No newline at end of file