-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
52 lines (39 loc) · 1.49 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
.PHONY: build help images push
ARCH ?= amd64
BIN_NAME = clair-load-test
BIN_DIR = bin
BIN_PATH = $(BIN_DIR)/$(ARCH)/$(BIN_NAME)
CGO = 0
SOURCES := $(shell find . -type f -name "*.go")
# Containers
ENGINE ?= podman
REGISTRY = quay.io
ORG ?= clair-load-test
CONTAINER_NAME_ARCH = $(REGISTRY)/$(ORG)/clair-load-test:$(ARCH)
all: lint build images push
help:
@echo "Commands for $(BIN_PATH):"
@echo
@echo 'Usage:'
@echo ' make clean Clean the compiled binaries'
@echo ' [ARCH=arch] make build Compile the project for arch, default amd64'
@echo ' [ARCH=arch] make install Installs clair-load-test binary in the system, default amd64'
@echo ' [ARCH=arch] make images Build images for arch, default amd64'
@echo ' [ARCH=arch] make push Push images for arch, default amd64'
@echo ' make help Show this message'
build: $(BIN_PATH)
$(BIN_PATH): $(SOURCES)
@echo -e "\033[2mBuilding $(BIN_PATH)\033[0m"
@echo "GOPATH=$(GOPATH)"
GOARCH=$(ARCH) CGO_ENABLED=$(CGO) go build -v -mod vendor -o $(BIN_PATH) ./cmd/clair-load-test
lint:
find . -name '*.go' -type f -exec go fmt {} \;
golangci-lint run
install:
cp $(BIN_PATH) /usr/bin/$(BIN_NAME)
images:
@echo -e "\n\033[2mBuilding container $(CONTAINER_NAME_ARCH)\033[0m"
$(ENGINE) build --arch=$(ARCH) -f Containerfile $(BIN_DIR)/$(ARCH)/ -t $(CONTAINER_NAME_ARCH)
push:
@echo -e "\033[2mPushing container $(CONTAINER_NAME_ARCH)\033[0m"
$(ENGINE) push $(CONTAINER_NAME_ARCH)