forked from aler9/rtsp-simple-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
127 lines (105 loc) · 2.8 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.PHONY: $(shell ls)
BASE_IMAGE = amd64/golang:1.14-alpine3.11
help:
@echo "usage: make [action]"
@echo ""
@echo "available actions:"
@echo ""
@echo " mod-tidy run go mod tidy"
@echo " format format source files"
@echo " test run available tests"
@echo " run ARGS=args run app"
@echo " release build release assets"
@echo " travis-setup setup travis CI"
@echo ""
blank :=
define NL
$(blank)
endef
mod-tidy:
docker run --rm -it -v $(PWD):/s $(BASE_IMAGE) \
sh -c "apk add git && cd /s && GOPROXY=direct go get && GOPROXY=direct go mod tidy"
format:
docker run --rm -it -v $(PWD):/s $(BASE_IMAGE) \
sh -c "cd /s && find . -type f -name '*.go' | xargs gofmt -l -w -s"
define DOCKERFILE_TEST
FROM $(BASE_IMAGE)
RUN apk add --no-cache make docker-cli git
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
endef
export DOCKERFILE_TEST
test:
echo "$$DOCKERFILE_TEST" | docker build -q . -f - -t temp
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
temp \
make test-nodocker
test-nodocker:
$(foreach IMG,$(shell echo test-images/*/ | xargs -n1 basename), \
docker build -q test-images/$(IMG) -t rtsp-sidecar-proxy-test-$(IMG)$(NL))
$(eval export CGO_ENABLED = 0)
go test -v .
define DOCKERFILE_RUN
FROM $(BASE_IMAGE)
RUN apk add --no-cache git
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN GOPROXY=direct go build -o /out .
endef
export DOCKERFILE_RUN
define CONFFILE
server:
protocols: [ tcp, udp ]
rtspPort: 8555
rtpPort: 8050
rtcpPort: 8051
streams:
test1:
url: rtsp://localhost:8554/mystream
endef
export CONFFILE
ARGS ?= stdin
run:
echo "$$DOCKERFILE_RUN" | docker build -q . -f - -t temp
echo "$$CONFFILE" | docker run --rm -i \
--network=host \
temp \
/out $(ARGS)
define DOCKERFILE_RELEASE
FROM $(BASE_IMAGE)
RUN apk add --no-cache zip make git tar
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN make release-nodocker
endef
export DOCKERFILE_RELEASE
release:
echo "$$DOCKERFILE_RELEASE" | docker build . -f - -t temp \
&& docker run --rm -it -v $(PWD):/out \
temp sh -c "rm -rf /out/release && cp -r /s/release /out/"
release-nodocker:
$(eval VERSION := $(shell git describe --tags))
$(eval GOBUILD := go build -ldflags '-X "main.Version=$(VERSION)"')
rm -rf release && mkdir release
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-sidecar-proxy
tar -C /tmp -czf $(PWD)/release/rtsp-sidecar-proxy_$(VERSION)_linux_amd64.tar.gz --owner=0 --group=0 rtsp-sidecar-proxy
define DOCKERFILE_TRAVIS
FROM ruby:alpine
RUN apk add --no-cache build-base git
RUN gem install travis
endef
export DOCKERFILE_TRAVIS
travis-setup:
echo "$$DOCKERFILE_TRAVIS" | docker build - -t temp
docker run --rm -it \
-v $(PWD):/s \
temp \
sh -c "cd /s \
&& travis setup releases --force"