-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (58 loc) · 2.08 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
61
62
63
64
65
66
67
68
SHELL := /bin/bash
IMAGE_NAME := $(shell basename "$$(pwd)")-app
BUILDER := extend-builder
GOLANG_DOCKER_IMAGE := golang:1.22
TEST_SAMPLE_CONTAINER_NAME := sample-override-test
proto:
rm -rfv pkg/pb/*
mkdir -p pkg/pb
docker run -t --rm -u $$(id -u):$$(id -g) -v $$(pwd):/data/ -w /data/ rvolosatovs/protoc:4.0.0 \
--proto_path=pkg/proto --go_out=pkg/pb \
--go_opt=paths=source_relative --go-grpc_out=pkg/pb \
--go-grpc_opt=paths=source_relative pkg/proto/*.proto
lint:
rm -f lint.err
find -type f -iname go.mod -exec dirname {} \; | while read DIRECTORY; do \
echo "# $$DIRECTORY"; \
docker run -t --rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/data/ \
-w /data/ \
-e GOCACHE=/data/.cache/go-build \
-e GOLANGCI_LINT_CACHE=/data/.cache/go-lint \
golangci/golangci-lint:v1.54.1\
sh -c "cd $$DIRECTORY \
&& golangci-lint \
-v \
--timeout 5m \
--max-same-issues 0 \
--max-issues-per-linter 0 \
--color never run \
|| touch /data/lint.err"; \
done
[ ! -f lint.err ] || (rm lint.err && exit 1)
build: proto
docker run -t --rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/data/ \
-w /data/ \
-e GOCACHE=/data/.cache/go-build \
$(GOLANG_DOCKER_IMAGE) \
sh -c "go build"
image:
docker buildx build -t ${IMAGE_NAME} --load .
imagex:
docker buildx inspect $(BUILDER) || docker buildx create --name $(BUILDER) --use
docker buildx build -t ${IMAGE_NAME} --platform linux/amd64 .
docker buildx build -t ${IMAGE_NAME} --load .
docker buildx rm --keep-state $(BUILDER)
imagex_push:
@test -n "$(IMAGE_TAG)" || (echo "IMAGE_TAG is not set (e.g. 'v0.1.0', 'latest')"; exit 1)
@test -n "$(REPO_URL)" || (echo "REPO_URL is not set"; exit 1)
docker buildx inspect $(BUILDER) || docker buildx create --name $(BUILDER) --use
docker buildx build -t ${REPO_URL}:${IMAGE_TAG} --platform linux/amd64 --push .
docker buildx rm --keep-state $(BUILDER)
ngrok:
@which ngrok || (echo "ngrok is not installed" ; exit 1)
@test -n "$(NGROK_AUTHTOKEN)" || (echo "NGROK_AUTHTOKEN is not set" ; exit 1)
ngrok tcp 6565 # gRPC server port