forked from 18F/redis-sentinel-proxy
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
74 lines (61 loc) · 1.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
SHA1 := $(shell git rev-parse HEAD)
SHORT_SHA1 := $(shell git rev-parse --short HEAD)
ORIGIN := $(shell git remote get-url origin)
DATE := $(date -u +'%Y-%m-%dT%H:%M:%Sz')
VER := $(shell git describe --tags --abbrev=0)
DOCK_REPO := patrickdk/redis-sentinel-proxy
export DOCKERFILE_PATH=Dockerfile
export DOCKER_REPO=$(DOCK_REPO)
export DOCKER_TAG=latest
export GIT_BRANCH=$(BRANCH)
export GIT_SHA1=$(SHA1)
export GIT_TAG=$(SHA1)
export GIT_VERSION=$(VER)
export GIT_VERSION_MAJOR=$(shell echo $(VER) | cut -f1 -d.)
export GIT_VERSION_MINOR=$(shell echo $(VER) | cut -f2 -d.)
export IMAGE_NAME=$(DOCKER_REPO):$(DOCKER_TAG)
export SOURCE_BRANCH=$(BRANCH)
export SOURCE_COMMIT=$(SHA1)
export SOURCE_TYPE=git
export SOURCE_REPOSITORY_URL=$(ORIGIN)
all: buildx
buildx:
docker buildx build --pull --push \
--platform linux/amd64,linux/arm64 \
--build-arg BUILD_GOOS=linux \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg BUILD_REF=${GIT_SHORT_SHA1} \
--build-arg BUILD_VERSION=${GIT_VERSION} \
--build-arg BUILD_REPO=${BUILD_REPO} \
--file ${DOCKERFILE_PATH} \
--tag ${DOCKER_REPO}:${GIT_VERSION} \
--tag ${DOCKER_REPO}:${GIT_VERSION_MAJOR} \
--tag ${DOCKER_REPO}:${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR} \
--tag ${IMAGE_NAME} \
.
build: export DOCKER_TAG=$(GIT_VERSION)
build: docker
release: export DOCKER_TAG=$(GIT_VERSION)
release: export DOCKER_EXTRATAGS=latest
release: release-publish
docker:
./hooks/post_checkout
./hooks/pre_build
./hooks/build
# ./hooks/push
release-publish:
./hooks/push
deps:
go get .
run-docker: ## Run dockerized service directly
docker run $(DOCKER_REPO):latest
push: ## docker push image to registry
docker push $(DOCKER_REPO):latest
build-local: ## Build the project
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build .
docker build -t $(DOCKER_REPO):latest .
run: ## Build and run the project
go build . && ./redis-sentinel-proxy
clean:
-rm -rf build