Skip to content

Commit

Permalink
feat: Add goreleaser and docker release steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Sharma committed Dec 4, 2019
1 parent 99442b6 commit 5fad4a3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ tsconfig.json
jsconfig.json

### Misc ###
# config.toml
config.toml
.goreleaser.yml
.DS_Store
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
.PHONY : build prod run fresh test clean
.PHONY : build prod run fresh test clean docker-build docker-push

BIN := calert.bin

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}'"
Expand Down
7 changes: 3 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5fad4a3

Please sign in to comment.