From ffddf10dfb8ed90f749cc4cd46f157cfb8a25713 Mon Sep 17 00:00:00 2001 From: Jon Buckley Date: Mon, 23 Jan 2017 15:58:30 -0500 Subject: [PATCH] fix(docker): Only build docker image on master or tag (#4644) r=vladikoff --- circle.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/circle.yml b/circle.yml index 8edf1e6f6..ed4b6890c 100644 --- a/circle.yml +++ b/circle.yml @@ -29,3 +29,48 @@ test: # retry the build if the attempt failed - retry -n 1 -- npm run test-circle firefoxBinary=/home/ubuntu/fxa-content-server/firefox/firefox: parallel: true + +# appropriately tag and push the container to dockerhub +deployment: + hub_latest: + branch: "master" + commands: + - "[ ! -z $DOCKERHUB_REPO ]" + - git clean -d --force -x + - docker info + - mkdir -p config + - > + printf '{"version":{"hash":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}}\n' + "$CIRCLE_SHA1" + "$CIRCLE_TAG" + "$CIRCLE_PROJECT_USERNAME" + "$CIRCLE_PROJECT_REPONAME" + "$CIRCLE_BUILD_URL" + | tee config/version.json version.json + - docker build -f Dockerfile-build -t fxa-content-server:build . + - docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASS" + - "docker tag fxa-content-server:build ${DOCKERHUB_REPO}:latest" + - "docker push ${DOCKERHUB_REPO}:latest" + + hub_releases: + # push all tags + tag: /.*/ + commands: + - "[ ! -z $DOCKERHUB_REPO ]" + - git clean -d --force -x + - docker info + - mkdir -p config + - > + printf '{"version":{"hash":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}}\n' + "$CIRCLE_SHA1" + "$CIRCLE_TAG" + "$CIRCLE_PROJECT_USERNAME" + "$CIRCLE_PROJECT_REPONAME" + "$CIRCLE_BUILD_URL" + | tee config/version.json version.json + - docker build -f Dockerfile-build -t fxa-content-server:build . + - docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASS" + - "echo ${DOCKERHUB_REPO}:${CIRCLE_TAG}" + - "docker tag fxa-content-server:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}" + - "docker images" + - "docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}"