-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (63 loc) · 1.58 KB
/
Copy pathMakefile
File metadata and controls
80 lines (63 loc) · 1.58 KB
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
73
74
75
76
77
78
79
80
DOCKER_REGISTRY ?= docker.io
IMAGE_PREFIX ?= enricofoltran
SHORT_NAME ?= simple-go-server
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:latest
# build options
GO ?= go
TAGS :=
LDFLAGS := -w -s
GOFLAGS :=
BINDIR := $(CURDIR)/bin
.PHONY: all
all: build
.PHONY: build
build:
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
.PHONY: clean
clean:
@rm -rf $(BINDIR) coverage.out coverage.html
.PHONY: test
test:
$(GO) test -v -race -coverprofile=coverage.out ./...
.PHONY: coverage
coverage: test
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
.PHONY: test-short
test-short:
$(GO) test -v -short ./...
.PHONY: bench
bench:
$(GO) test -v -bench=. -benchmem ./...
.PHONY: vet
vet:
$(GO) vet ./...
.PHONY: fmt
fmt:
$(GO) fmt ./...
.PHONY: lint
lint: vet fmt
@echo "Linting complete"
.PHONY: check
check: lint test
@echo "All checks passed"
.PHONY: run
run:
$(GO) run main.go
.PHONY: check-docker
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing 'docker' client which is required for development"; \
exit 2; \
fi
.PHONY: docker-binary
docker-binary: BINDIR = $(CURDIR)/rootfs
docker-binary: GOFLAGS += -a -installsuffix cgo
docker-binary:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o $(BINDIR)/$(SHORT_NAME) $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
.PHONY: docker-build
docker-build: check-docker docker-binary
docker build --rm -t ${IMAGE} rootfs
.PHONY: docker-push
docker-push: docker-build
docker push ${IMAGE}