-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
55 lines (47 loc) · 1.14 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
DOCKER ?= docker
GOLANG_VERSION ?= 1.23-alpine
IMAGE ?= elasticdump
VERSION ?= latest
GOOS ?= linux
GOARCH ?= amd64
GOPROXY ?= $(shell printenv GOPROXY)
LDFLAGS ?= "-s -w"
.PHONY: all
all: elasticdump
.PHONY: elasticdump
elasticdump:
go build -v -o $@
.PHONY: docker-build
docker-build:
$(DOCKER) run --rm --name elasticdump-build -it \
-v $(shell pwd):/build \
--workdir /build \
--user $(shell id -u):$(shell id -g) \
--env XDG_CACHE_HOME=/tmp/.cache \
--env GOOS=$(GOOS) \
--env GOARCH=$(GOARCH) \
--env GOPROXY=$(GOPROXY) \
--env CGO_ENABLED=0 \
golang:$(GOLANG_VERSION) \
go build -v -ldflags=$(LDFLAGS) -buildvcs=false -o elasticdump-$(GOOS)-$(GOARCH)
.PHONY: img
img:
$(DOCKER) build \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg GOPROXY=$(GOPROXY) \
--build-arg LDFLAGS=$(LDFLAGS) \
--tag $(IMAGE):$(VERSION) \
--file docker/Dockerfile \
.
.PHONY: tidy
tidy:
go mod tidy
.PHONY: lint
lint:
golangci-lint run -v --timeout 10m ./cmd/... ./pkg/...
.PHONY: test
test:
go test -count=1 ./cmd/... ./pkg/...
.PHONY: clean
clean:
rm -fr elasticdump*