From 5fad4a320c7d548f869c0eb6374c1fd16dad6f44 Mon Sep 17 00:00:00 2001 From: Karan Sharma Date: Wed, 4 Dec 2019 09:56:06 +0530 Subject: [PATCH] feat: Add goreleaser and docker release steps --- .gitignore | 2 +- Makefile | 10 +++++++++- docker/Dockerfile | 7 +++---- go.mod | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b658b2f..0ef6c55 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,6 @@ tsconfig.json jsconfig.json ### Misc ### -# config.toml +config.toml .goreleaser.yml .DS_Store \ No newline at end of file diff --git a/Makefile b/Makefile index d59d611..8bea07e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : build prod run fresh test clean +.PHONY : build prod run fresh test clean docker-build docker-push BIN := calert.bin @@ -6,7 +6,15 @@ HASH := $(shell git rev-parse --short HEAD) COMMIT_DATE := $(shell git show -s --format=%ci ${HASH}) BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S') VERSION := ${HASH} (${COMMIT_DATE}) +CALERT_IMAGE := mrkaran/calert +CALERT_TAG := 1.1.0 +docker-build: + docker build -t ${CALERT_IMAGE}:latest -t ${CALERT_IMAGE}:${CALERT_TAG} -f docker/Dockerfile . + +docker-push: + docker push ${CALERT_IMAGE}:latest + docker push ${CALERT_IMAGE}:${CALERT_TAG} build: go build -o ${BIN} -ldflags="-X 'main.version=${VERSION}' -X 'main.date=${BUILD_DATE}'" diff --git a/docker/Dockerfile b/docker/Dockerfile index 2b6ca1f..a21d374 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,9 @@ -ARG GO_VERSION=1.12 +ARG GO_VERSION=1.13 FROM golang:${GO_VERSION}-alpine AS builder -RUN apk update && apk add gcc libc-dev make git +RUN apk update && apk add make git WORKDIR /calert/ COPY ./ ./ -ENV CGO_ENABLED=0 GOFLAGS=-mod=vendor GOOS=linux +ENV CGO_ENABLED=0 GOOS=linux RUN make build FROM alpine:latest AS deploy @@ -14,4 +14,3 @@ RUN mkdir -p /etc/calert && cp config.toml.sample /etc/calert/config.toml # Define data volumes VOLUME ["/etc/calert"] CMD ["./calert.bin", "--config.file", "/etc/calert/config.toml"] - diff --git a/go.mod b/go.mod index 02a73ac..71c83ae 100644 --- a/go.mod +++ b/go.mod @@ -10,3 +10,5 @@ require ( github.com/spf13/viper v1.3.1 golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect ) + +go 1.13