-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (37 loc) · 1.03 KB
/
Makefile
File metadata and controls
43 lines (37 loc) · 1.03 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
COMMIT := $(shell git rev-parse --short HEAD)
VERSION := $(shell \
TAG=$$(git describe --tags --exact-match 2>/dev/null || true); \
if [ -n "$$TAG" ]; then \
echo "$$TAG"; \
elif [ "$$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" != "HEAD" ]; then \
git rev-parse --abbrev-ref HEAD; \
else \
git describe --tags --always --dirty; \
fi \
)
GO_VERSION := $(shell go version | awk '{print $$3}')
REPO := github.com/brasilcep/api
build:
@echo "Building version $(VERSION) (commit: $(COMMIT))"
go build -ldflags "\
-X 'main.Version=$(VERSION)' \
-X 'main.Commit=$(COMMIT)' \
-X 'main.Repo=$(REPO)' \
-X 'main.Compiler=$(GO_VERSION)' \
" -o wserver main.go
test:
go test -v ./......
lint:
golangci-lint run --timeout 5m
docker-build:
tar -czf data.tar.gz data/
docker build -t brasilcep/api:dev .
run-docker:
docker run --cpus="0.5" --memory="512m" \
-p 8080:8080 \
brasilcep/api:dev
benchmark-docker:
docker compose up brasilcep-api -d
@echo "Waiting for the API to start and load data..."
sleep 120
docker compose up