From 6a2d9b5080c5a88a471523c6a30f41ad893f8cfa Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Thu, 7 May 2020 15:50:54 -0400 Subject: [PATCH 1/2] Trying something else --- .travis.yml | 2 +- Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 495151a..1f7d01d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ deploy: skip_cleanup: true on: all_branches: true - condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$ +# condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$ notifications: email: diff --git a/Dockerfile b/Dockerfile index 3abddd6..87d8362 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM postgres ARG GIT_COMMIT="" -RUN echo "GIT_COMMIT = ${GIT_COMMIT}" +CMD echo 'echo "git commit = ${GIT_COMMIT}"' >> ./initdb.sh COPY ./initdb.sh /docker-entrypoint-initdb.d/initdb.sh -CMD echo 'echo "git commit = ${GIT_COMMIT}"' >> /docker-entrypoint-initdb.d/initdb.sh EXPOSE 5432 From 90197c28cd1ad334fea71487875f6c7ae817e814 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Thu, 7 May 2020 15:55:03 -0400 Subject: [PATCH 2/2] Fails build if any deploy step fails --- .travis.yml | 2 +- deploy.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f7d01d..495151a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ deploy: skip_cleanup: true on: all_branches: true -# condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$ + condition: $TRAVIS_BRANCH =~ ^(testing|staging|master)$ notifications: email: diff --git a/deploy.sh b/deploy.sh index 4ad34dc..adfd555 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,16 +1,16 @@ #!/bin/bash # Build and push Docker image to Docker Hub -echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin +echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1 APP="db" REPO="sartography/cr-connect-$APP" TAG=$(if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH" ; fi) COMMIT=${TRAVIS_COMMIT::8} -docker build -f Dockerfile -t "$REPO:$COMMIT" --build-arg GIT_COMMIT="$REPO:$COMMIT" . -docker tag "$REPO:$COMMIT" "$REPO:$TAG" -docker tag "$REPO:$COMMIT" "$REPO:travis-$TRAVIS_BUILD_NUMBER" -docker push "$REPO" +docker build -f Dockerfile -t "$REPO:$COMMIT" --build-arg GIT_COMMIT="$REPO:$COMMIT" . || exit 1 +docker tag "$REPO:$COMMIT" "$REPO:$TAG" || exit 1 +docker tag "$REPO:$COMMIT" "$REPO:travis-$TRAVIS_BUILD_NUMBER" || exit 1 +docker push "$REPO" || exit 1 # Wait for Docker Hub echo "Publishing to Docker Hub..." @@ -18,4 +18,4 @@ sleep 30 # Notify UVA DCOS that Docker image has been updated echo "Refreshing DC/OS..." -aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$TRAVIS_BRANCH/$APP" +aws sqs send-message --region "$AWS_DEFAULT_REGION" --queue-url "$AWS_SQS_URL" --message-body "crconnect/$TRAVIS_BRANCH/$APP" || exit 1