From 757e748e3f3b84cb41592cd6aadb0f80ae8181b0 Mon Sep 17 00:00:00 2001 From: abdennour Date: Mon, 3 Feb 2020 02:45:51 +0300 Subject: [PATCH] Feature/autobuild docker image for each release thru dockerhub auto builds (#886) * feat: build hook for dockerhub autobuilds * release new image * Create pre_build * Update push --- hooks/build | 6 ++++++ hooks/pre_build | 9 +++++++++ hooks/push | 11 +++++++++++ 3 files changed, 26 insertions(+) create mode 100644 hooks/build create mode 100644 hooks/pre_build create mode 100644 hooks/push diff --git a/hooks/build b/hooks/build new file mode 100644 index 00000000..880a27eb --- /dev/null +++ b/hooks/build @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "=> Building container" +docker build \ + --tag "$IMAGE_NAME" \ + --file Dockerfile . diff --git a/hooks/pre_build b/hooks/pre_build new file mode 100644 index 00000000..c40252a1 --- /dev/null +++ b/hooks/pre_build @@ -0,0 +1,9 @@ +#!/bin/bash + +go() +{ + docker run --rm -v "$(pwd):/workspace" -w /workspace golang:latest go $@; +} + +go get -u github.com/tcnksm/ghr github.com/mitchellh/gox +go mod vendor diff --git a/hooks/push b/hooks/push new file mode 100644 index 00000000..21ca2daa --- /dev/null +++ b/hooks/push @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "=> Fetch unshallow origin" +git fetch --unshallow origin || true + +echo "=> Tag image:" +docker tag "${IMAGE_NAME}" "${DOCKER_REPO}:$(git describe --tags --abbrev=0 HEAD^)" +docker tag "${IMAGE_NAME}" "${DOCKER_REPO}:$(git describe --tags --abbrev=0 HEAD)" + +echo "=> Push images" +docker push "${DOCKER_REPO}"