forked from lwolf/kubereplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (58 loc) · 1.87 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
NAME := kube-replay
AUTHOR=lwolf
VERSION ?= 0.0.1
REGISTRY ?= quay.io
GIT_SHA=$(shell git --no-pager describe --always --dirty)
BUILD_TIME=$(shell date '+%s')
LFLAGS ?= -X main.gitsha=${GIT_SHA} -X main.compiled=${BUILD_TIME}
ROOT_DIR=${PWD}
GOVERSION ?= 1.9.3
HARDWARE=$(shell uname -m)
.PHONY: changelog build build-controller build-initializer docker static release install_deps
golang:
@echo "--> Go Version"
@go version
build-info:
@echo "building ${GIT_SHA} from ${BUILD_TIME}"
install_deps:
dep ensure
build: golang build-info
@echo "--> Compiling the project"
@mkdir -p bin
go build -ldflags "${LFLAGS}" -o bin/${NAME}-controller cmd/controller/main.go
go build -ldflags "${LFLAGS}" -o bin/${NAME}-initializer cmd/initializer/main.go
build-image: bin/linux/$(OPERATOR_NAME)
docker build . -t $(IMAGE):$(VERSION)
build-controller: golang build-info
@echo "--> Compiling the project"
@mkdir -p bin
go build -o bin/${NAME}-controller cmd/controller/main.go
build-initializer: golang build-info
@echo "--> Compiling the project"
@mkdir -p bin
go build -o bin/${NAME}-initializer cmd/initializer/main.go
docker-build:
@echo "--> Compiling the project"
docker run --rm \
-v ${ROOT_DIR}:/go/src/github.com/${AUTHOR}/${NAME} \
-w /go/src/github.com/${AUTHOR}/${NAME} \
-e GOOS=linux golang:${GOVERSION} \
make static
docker-release:
@echo "--> Building a release image"
@$(MAKE) static
@$(MAKE) docker
@docker push ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION}
docker:
@echo "--> Building the docker image"
docker build -t ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION} .
static: golang
@echo "--> Compiling the static binary"
@mkdir -p bin
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a -tags netgo -ldflags "-w ${LFLAGS}" -o bin/${NAME} ./cmd/controller
clean:
rm -rf ./bin 2>/dev/null
rm -rf ./release 2>/dev/null
format:
@echo "--> Running go fmt"
@gofmt -s -w ./