-
Notifications
You must be signed in to change notification settings - Fork 77
/
Makefile
60 lines (41 loc) · 1.12 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
.PHONY: build images
# Development
build_rev := "main"
ifneq ($(wildcard .git),)
build_rev := $(shell git rev-parse --short HEAD)
endif
build_date := $(shell date -u '+%Y-%m-%dT%H:%M:%S')
setup:
@go mod download
lint:
@golangci-lint run --print-issued-lines=false --out-format=colored-line-number ./...
vet:
@go vet ./...
test:
@go test ./... -v
build:
@go build -ldflags "-X main.commit=$(build_rev) -X main.date=$(build_date)" -o build/codapi -v cmd/main.go
run:
@./build/codapi
# Containers
images:
docker build --file images/alpine/Dockerfile --tag codapi/alpine:latest images/alpine/
network:
docker network create --internal codapi
# Host OS
mount-tmp:
mount -t tmpfs tmpfs /tmp -o rw,exec,nosuid,nodev,size=64m,mode=1777
# Deployment
app-download:
@curl -L -o codapi.zip "https://api.github.com/repos/nalgeon/codapi/actions/artifacts/$(id)/zip"
@unzip -ou codapi.zip
@chmod +x build/codapi
@rm -f codapi.zip
@echo "OK"
app-start:
@nohup build/codapi > codapi.log 2>&1 & echo $$! > codapi.pid
@echo "started codapi"
app-stop:
@kill $(shell cat codapi.pid)
@rm -f codapi.pid
@echo "stopped codapi"