-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
61 lines (47 loc) · 1.71 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
BIN=bin
IMAGE_NAME=freenas-provisioner
IMAGE_VERSION=2.7
REMOTE_NAME=$(DOCKER_ID_USER)/$(IMAGE_NAME)
.PHONY: all
all: build
.PHONY: fmt
fmt:
go fmt ./...
tmp:
mkdir -p tmp/
$(BIN):
mkdir -p $(BIN)
.PHONY: image
image: tmp check-docker-hub
wget -O tmp/freenas-provisioner https://github.com/nmaupu/freenas-provisioner/releases/download/v$(IMAGE_VERSION)/freenas-provisioner_linux-amd64 && \
chmod +x tmp/freenas-provisioner
docker build -t $(IMAGE_NAME):$(IMAGE_VERSION) -f Dockerfile .
.PHONY: tag
tag: image
docker tag $(IMAGE_NAME):$(IMAGE_VERSION) $(REMOTE_NAME):$(IMAGE_VERSION)
.PHONY: push
push: tag
docker push $(REMOTE_NAME):$(IMAGE_VERSION)
.PHONY: build
$(BIN)/freenas-provisioner build: $(BIN) $(shell find . -name "*.go")
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o $(BIN)/freenas-provisioner .
.PHONY: linuxarm
$(BIN)/freenas-provisioner-arm linuxarm: $(BIN) $(shell find . -name "*.go")
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -ldflags '-extldflags "-static"' -o $(BIN)/freenas-provisioner-arm .
.PHONY: darwin
$(BIN)/freenas-provisioner-darwin darwin: $(BIN) $(shell find . -name "*.go")
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o $(BIN)/freenas-provisioner-darwin .
.PHONY: freebsd
$(BIN)/freenas-provisioner-freebsd freebsd: $(BIN) $(shell find . -name "*.go")
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o $(BIN)/freenas-provisioner-freebsd .
.PHONY: clean
clean:
go clean -i
rm -rf $(BIN)
rm -rf tmp
rm -rf vendor
.PHONY: check-docker-hub
check-docker-hub:
ifndef DOCKER_ID_USER
$(error ERROR! DOCKER_ID_USER environment variable must be defined)
endif