diff --git a/.circleci/config.yml b/.circleci/config.yml index 5346e4612d..70b9055abb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -201,6 +201,21 @@ jobs: exit 1 fi + # upload dev docker image + dev-upload-docker: + docker: + - image: circleci/golang:latest # use a circleci image so the attach_workspace step works (has ca-certs installed) + environment: + <<: *ENVIRONMENT + steps: + - checkout + # get consul binary + - attach_workspace: + at: bin/ + - setup_remote_docker: + docker_layer_caching: true + - run: make ci.dev-docker + # Nomad 0.8 builds on go0.10 # Run integration tests on nomad/v0.8.7 nomad-integration-0_8: @@ -457,13 +472,16 @@ workflows: test-integrations: jobs: - dev-build - - dev-upload-s3: + - dev-upload-s3: &dev-upload requires: - dev-build filters: branches: ignore: - /^pull\/.*$/ # only push dev builds from non forks + - dev-upload-docker: + <<: *dev-upload + context: consul-ci - nomad-integration-master: requires: - dev-build diff --git a/GNUmakefile b/GNUmakefile index bee271760b..79cf365f30 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -47,6 +47,14 @@ UI_BUILD_TAG?=consul-build-ui BUILD_CONTAINER_NAME?=consul-builder CONSUL_IMAGE_VERSION?=latest +################ +# CI Variables # +################ +CI_DEV_DOCKER_NAMESPACE?=hashicorpdev +CI_DEV_DOCKER_IMAGE_NAME?=consul +CI_DEV_DOCKER_WORKDIR?=bin/ +################ + DIST_TAG?=1 DIST_BUILD?=1 DIST_SIGN?=1 @@ -131,6 +139,26 @@ dev-docker: linux @echo "Building Consul Development container - $(CONSUL_DEV_IMAGE)" @docker build $(NOCACHE) $(QUIET) -t '$(CONSUL_DEV_IMAGE)' --build-arg CONSUL_IMAGE_VERSION=$(CONSUL_IMAGE_VERSION) $(CURDIR)/pkg/bin/linux_amd64 -f $(CURDIR)/build-support/docker/Consul-Dev.dockerfile +# In CircleCI, the linux binary will be attached from a previous step at bin/. This make target +# should only run in CI and not locally. +ci.dev-docker: + @echo "Pulling consul container image - $(CONSUL_IMAGE_VERSION)" + @docker pull consul:$(CONSUL_IMAGE_VERSION) >/dev/null + @echo "Building Consul Development container - $(CI_DEV_DOCKER_IMAGE_NAME)" + @docker build $(NOCACHE) $(QUIET) -t '$(CI_DEV_DOCKER_NAMESPACE)/$(CI_DEV_DOCKER_IMAGE_NAME):$(GIT_COMMIT)' \ + --build-arg CONSUL_IMAGE_VERSION=$(CONSUL_IMAGE_VERSION) \ + --label COMMIT_SHA=$(CIRCLE_SHA1) \ + --label PULL_REQUEST=$(CIRCLE_PULL_REQUEST) \ + --label CIRCLE_BUILD_URL=$(CIRCLE_BUILD_URL) \ + $(CI_DEV_DOCKER_WORKDIR) -f $(CURDIR)/build-support/docker/Consul-Dev.dockerfile + @echo $(DOCKER_PASS) | docker login -u="$(DOCKER_LOGIN)" --password-stdin + @echo "Pushing dev image to: https://cloud.docker.com/u/hashicorpdev/repository/docker/hashicorpdev/consul" + @docker push $(CI_DEV_DOCKER_NAMESPACE)/$(CI_DEV_DOCKER_IMAGE_NAME):$(GIT_COMMIT) +ifeq ($(CIRCLE_BRANCH), master) + @docker tag $(CI_DEV_DOCKER_NAMESPACE)/$(CI_DEV_DOCKER_IMAGE_NAME):$(GIT_COMMIT) $(CI_DEV_DOCKER_NAMESPACE)/$(CI_DEV_DOCKER_IMAGE_NAME):latest + @docker push $(CI_DEV_DOCKER_NAMESPACE)/$(CI_DEV_DOCKER_IMAGE_NAME):latest +endif + changelogfmt: @echo "--> Making [GH-xxxx] references clickable..." @sed -E 's|([^\[])\[GH-([0-9]+)\]|\1[[GH-\2](https://github.com/hashicorp/consul/issues/\2)]|g' CHANGELOG.md > changelog.tmp && mv changelog.tmp CHANGELOG.md