-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (47 loc) · 1.25 KB
/
Makefile
File metadata and controls
65 lines (47 loc) · 1.25 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
.PHONY: build
# 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 ./...
@echo "✓ lint"
vet:
@go vet ./...
@echo "✓ vet"
test:
@go test ./...
@echo "✓ test"
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
image:
@[ -n "$(name)" ] || (echo "Syntax: make image name=<image-name>" >&2; exit 1)
@echo "Building image codapi/$(name)"
@docker build --file sandboxes/$(name)/Dockerfile --tag codapi/$(name):latest sandboxes/$(name)/
@echo "✓ codapi/$(name)"
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"