-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (24 loc) · 733 Bytes
/
Makefile
File metadata and controls
34 lines (24 loc) · 733 Bytes
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
# Makefile
APPNAME=admitCtlr
IMAGE_NAME=liangrog/admission-webhook-server
DOCKERFILE=Dockerfile
VERSION_TAG=`git describe 2>/dev/null | cut -f 1 -d '-' 2>/dev/null`
COMMIT_HASH=`git rev-parse --short=8 HEAD 2>/dev/null`
BUILD_TIME=`date +%FT%T%z`
LDFLAGS=-ldflags "-s -w \
-X main.CommitHash=${COMMIT_HASH} \
-X main.BuildTime=${BUILD_TIME} \
-X main.Tag=${VERSION_TAG}"
all: clean test fast
test:
go test -v ./...
clean:
go clean
rm -r ./$(APPNAME) || true
fast:
go build -o ${APPNAME} ${LDFLAGS}
docker_binary:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o $(APPNAME) ${LDFLAGS} .
docker_build:
docker build . -f $(DOCKERFILE) -t $(IMAGE_NAME) --no-cache
docker: docker_binary docker_build