-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (43 loc) · 1.18 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
go_version ?= 1.16
image ?= ghcr.io/sngular/gitops-echobot
tag = $(shell git rev-parse --short HEAD)
pre-commit: tidy fmt vet clean
build:
go get && go build main.go
run:
go run main.go
fmt:
docker run --rm --name go-fmt \
-e $UID=$(shell id -u) \
-e $GUID=$(shell id -g) \
-v $(shell pwd):/app \
-v $(shell pwd)/.cache:/go/pkg \
-w /app golang:${go_version} go fmt ./...
git add **\*.go
tidy:
docker run --rm --name go-tidy \
-e $UID=$(shell id -u) \
-e $GUID=$(shell id -g) \
-v $(shell pwd):/app \
-v $(shell pwd)/.cache:/go/pkg \
-w /app golang:${go_version} go mod tidy
vet:
docker run --rm --name go-vet \
-e $UID=$(shell id -u) \
-e $GUID=$(shell id -g) \
-v $(shell pwd):/app \
-v $(shell pwd)/.cache:/go/pkg \
-w /app golang:${go_version} go vet ./...
clean:
@rm -rf main bin/ *.out
docker-build:
docker build --tag ${image}:${tag} .
docker-run: docker-build
docker container run --rm --name echobot --interactive \
-e OUTPUT_TYPE=${OUTPUT_TYPE} \
-e MESSAGE=${MESSAGE} \
-e SLEEP_TIME=${SLEEP_TIME} \
-e MONGODB_URI=${MONGODB_URI} \
-e MONGODB_DATABASE=${MONGODB_DATABASE} \
-e MONGODB_COLLECTION=${MONGODB_COLLECTION} \
${image}:${tag}