2020-02-06 23:58:07 +00:00
|
|
|
docker:
|
|
|
|
- image: circleci/buildpack-deps
|
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker
|
|
|
|
- run:
|
|
|
|
name: Build Docker Image if Necessary
|
|
|
|
command: |
|
2020-02-18 18:42:50 +00:00
|
|
|
# There is an edge case that would cause an issue here - if dependencies are updated to an exact copy
|
|
|
|
# of a previous version, for example if packge-lock.json is reverted, we need to manually push the new
|
|
|
|
# image to the "latest" tag
|
2020-02-19 14:18:43 +00:00
|
|
|
# Ignore job if running an enterprise build
|
2020-02-19 17:44:22 +00:00
|
|
|
IMAGE_TAG=$(cat website/Dockerfile website/package-lock.json | sha256sum | awk '{print $1;}')
|
|
|
|
echo "Using $IMAGE_TAG"
|
2020-03-20 19:43:36 +00:00
|
|
|
if [ "$CIRCLE_REPOSITORY_URL" != "git@github.com:hashicorp/nomad.git" ]; then
|
2020-02-19 17:44:22 +00:00
|
|
|
echo "Not Nomad OSS Repo, not building website docker image"
|
|
|
|
elif curl https://hub.docker.com/v2/repositories/hashicorp/nomad-website/tags/$IMAGE_TAG -fsL > /dev/null; then
|
|
|
|
echo "Dependencies have not changed, not building a new website docker image."
|
|
|
|
else
|
2020-02-19 14:18:43 +00:00
|
|
|
cd website/
|
|
|
|
docker build -t hashicorp/nomad-website:$IMAGE_TAG .
|
|
|
|
docker tag hashicorp/nomad-website:$IMAGE_TAG hashicorp/nomad-website:latest
|
|
|
|
docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_DOCKER_PASS
|
|
|
|
docker push hashicorp/nomad-website
|
2020-02-06 23:58:07 +00:00
|
|
|
fi
|