-
Notifications
You must be signed in to change notification settings - Fork 154
/
Makefile
56 lines (40 loc) · 1.08 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
VERSION := 0.0.1-dev
GO := go
GOOS := linux
DOCKER_TAG := 0.0.2-dev
BIN := opa-iptables
PKG := github.com/open-policy-agent/contrib/opa-iptables
BUILD_COMMIT := $(shell ./build/get-build-commit.sh)
LDFLAGS := "-X github.com/open-policy-agent/contrib/opa-iptables/pkg/version.Version=$(VERSION) \
-X github.com/open-policy-agent/contrib/opa-iptables/pkg/version.Commit=$(BUILD_COMMIT) \
-w"
GO111MODULE := on
.PHONY: all
all: test build push clean
.PHONY: version
version:
@echo $(VERSION)
.PHONY: build
build: docker-build
.PHONY: docker-build
docker-build:
@docker run --rm -v $$(pwd):/go/src/$(PKG) \
-e GOOS=$(GOOS) \
-e GO111MODULE=$(GO111MODULE) \
-w /go/src/$(PKG) golang:1.13-rc-alpine \
$(GO) build -o $(BIN) -ldflags $(LDFLAGS)
@docker build -t urvil38/opa-iptables:$(DOCKER_TAG) \
-f Dockerfile \
.
@echo Successfully built $(BIN)
push:
docker push urvil38/opa-iptables:$(DOCKER_TAG)
clean:
rm -f $(BIN) -y
go-build:
GOOS=$(GOOS) $(GO) build -o $(BIN) -ldflags $(LDFLAGS)
.PHONY: test
test: go-test
.PHONY: go-test
go-test:
$(GO) test -v -count=1 ./...