From 0bd192feec4271e260c589c04f9fdb257345f93a Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 9 Mar 2018 14:01:09 +0100 Subject: [PATCH] feat: official Dockerfile (#1619) Adds a Dockerfile for building with Docker Hub --- docker/Dockerfile | 16 ++++++++++++++++ docker/hooks/post_push | 20 ++++++++++++++++++++ docker/hooks/readme.md | 5 +++++ 3 files changed, 41 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/hooks/post_push create mode 100644 docker/hooks/readme.md diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..c3791795d4 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,16 @@ +FROM node:8.10.0-alpine + +LABEL maintainer="Rhys Arkins " +LABEL name="renovate" + +WORKDIR /src + +COPY package.json . +COPY yarn.lock . +RUN yarn install --production && yarn cache clean +COPY lib ./lib +RUN chown -R node:node /src +USER node + +ENTRYPOINT ["node", "/src/lib/renovate.js"] +CMD ["--help"] diff --git a/docker/hooks/post_push b/docker/hooks/post_push new file mode 100644 index 0000000000..22b6fe195f --- /dev/null +++ b/docker/hooks/post_push @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +SEMVER_REGEX="^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$" + +if ! [[ "$CACHE_TAG" =~ $SEMVER_REGEX ]]; then + echo Not a semver tag - skipping + exit +fi + +major=${BASH_REMATCH[1]} +minor=${BASH_REMATCH[2]} + +# Tag and push image for each additional tag +for tag in {"$major","${major}.${minor}"}; do + echo "Tagging ${DOCKER_REPO}:${tag}" + docker tag $IMAGE_NAME ${DOCKER_REPO}:${tag} + docker push ${DOCKER_REPO}:${tag} +done diff --git a/docker/hooks/readme.md b/docker/hooks/readme.md new file mode 100644 index 0000000000..2454928072 --- /dev/null +++ b/docker/hooks/readme.md @@ -0,0 +1,5 @@ +# Docker Hub hooks + +This directory is required in order to provide a post-push hook to Docker Hub Autobuild. + +See https://docs.docker.com/docker-cloud/builds/advanced/#custom-build-phase-hooks for details.