Skip to content

Commit 8b67b5b

Browse files
committed
add docker hub images
1 parent 60371af commit 8b67b5b

File tree

3 files changed

+108
-32
lines changed

3 files changed

+108
-32
lines changed

.travis.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
language: minimal
22

3+
dist: bionic
4+
35
services:
46
- docker
57

8+
# docker >= 19.03 is required for docker buildx, so it is upgraded
9+
before_install:
10+
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
11+
- sudo apt update -y
12+
- sudo apt install --only-upgrade docker-ce -y
13+
614
script:
715
- make test
8-
- make release
916

1017
deploy:
11-
provider: releases
12-
api_key:
13-
secure: RmEv6bgtRwQr7JDFHFNDbv2nKve8Y+299/S9Ez39ZobX4F8870Szl329OjnL2B82wYWQg3GzPZ6pkcsm6OUV1Xms+Bo0a+QIOTddmNmzOyd70+IG7BtFjDa4HQ7rrxOt/kr5NAOP0R9h5oVq1+mlMOMEeB6BBo4SNG4V3YIkuXxVUTOtiJdyJDlqIvjgei7PWIierazTmdDmEkvdeXWKfbMXFKWu8v+vNVXYXsq4rX4f4eyivNYQuOnCKKjr3XB4QAigRijbLubxpc+GAlEQrxSzQkHR95lLE/w6xUkeYM0qL0OF1W3+nWYk7C3gGYVHXIaSse+7+UqhGtroZmxtaiP5duvOhW8ikamvEcLkiYEfvnmTJDUldGR27xQZ7wJRvtWhl4TMqSCHBgTWvPtf7l55rLTZmibsrE0AttJZF1UkPoVQ+j/wvUP8azqaNiwDrDU6F7NHXn8jhoLfnELtPe9Ed6o0JHr+Asuv1sooOOU+af3Y8cYlFTH3+NResrGdSUQ0n9OkRIv1pHN2T/FTLL74HWS0tlahhA6FAIqxfbffypSrMP4NhcwC7YI0dystLxJd1BmOxFBn9ov+vfqNi7yhyG+bwEcFPfi6h0bd5xa3ni0erdKI1ner8GaQSThWkgGD91X+0Rg5VDN9OKg3lcpO7Xz+GbJUpMMuXWpuWcI=
18+
- provider: script
19+
script: make release
20+
on:
21+
repo: aler9/rtsp-simple-server
22+
tags: true
23+
24+
- provider: releases
25+
api_key: $GITHUB_API_KEY
1426
skip_cleanup: true
1527
file_glob: true
1628
file: release/*
1729
on:
1830
repo: aler9/rtsp-simple-server
1931
tags: true
32+
33+
- provider: script
34+
script: docker login -u aler9 -p $DOCKER_PASSWORD && make dockerhub
35+
on:
36+
repo: aler9/rtsp-simple-server
37+
tags: true

Makefile

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
.PHONY: $(shell ls)
33

4-
BASE_IMAGE = amd64/golang:1.14-alpine3.11
4+
BASE_IMAGE = golang:1.14-alpine3.11
55

66
help:
77
@echo "usage: make [action]"
@@ -13,7 +13,7 @@ help:
1313
@echo " test run available tests"
1414
@echo " run ARGS=args run app"
1515
@echo " release build release assets"
16-
@echo " travis-setup setup travis CI"
16+
@echo " dockerhub build and push docker hub images"
1717
@echo ""
1818

1919
blank :=
@@ -23,15 +23,15 @@ $(blank)
2323
endef
2424

2525
mod-tidy:
26-
docker run --rm -it -v $(PWD):/s $(BASE_IMAGE) \
26+
docker run --rm -it -v $(PWD):/s amd64/$(BASE_IMAGE) \
2727
sh -c "apk add git && cd /s && GOPROXY=direct go get && GOPROXY=direct go mod tidy"
2828

2929
format:
30-
docker run --rm -it -v $(PWD):/s $(BASE_IMAGE) \
30+
docker run --rm -it -v $(PWD):/s amd64/$(BASE_IMAGE) \
3131
sh -c "cd /s && find . -type f -name '*.go' | xargs gofmt -l -w -s"
3232

3333
define DOCKERFILE_TEST
34-
FROM $(BASE_IMAGE)
34+
FROM amd64/$(BASE_IMAGE)
3535
RUN apk add --no-cache make docker-cli git
3636
WORKDIR /s
3737
COPY go.mod go.sum ./
@@ -48,13 +48,13 @@ test:
4848
make test-nodocker
4949

5050
test-nodocker:
51+
$(eval export CGO_ENABLED=0)
5152
$(foreach IMG,$(shell echo test-images/*/ | xargs -n1 basename), \
5253
docker build -q test-images/$(IMG) -t rtsp-simple-server-test-$(IMG)$(NL))
53-
$(eval export CGO_ENABLED = 0)
5454
go test -v .
5555

5656
define DOCKERFILE_RUN
57-
FROM $(BASE_IMAGE)
57+
FROM amd64/$(BASE_IMAGE)
5858
RUN apk add --no-cache git
5959
WORKDIR /s
6060
COPY go.mod go.sum ./
@@ -72,7 +72,7 @@ run:
7272
/out $(ARGS)
7373

7474
define DOCKERFILE_RELEASE
75-
FROM $(BASE_IMAGE)
75+
FROM amd64/$(BASE_IMAGE)
7676
RUN apk add --no-cache zip make git tar
7777
WORKDIR /s
7878
COPY go.mod go.sum ./
@@ -88,39 +88,84 @@ release:
8888
temp sh -c "rm -rf /out/release && cp -r /s/release /out/"
8989

9090
release-nodocker:
91+
$(eval export CGO_ENABLED=0)
9192
$(eval VERSION := $(shell git describe --tags))
92-
$(eval GOBUILD := go build -ldflags '-X "main.Version=$(VERSION)"')
93+
$(eval GOBUILD := go build -ldflags '-X main.Version=$(VERSION)')
9394
rm -rf release && mkdir release
9495

95-
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-simple-server.exe
96+
GOOS=windows GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-simple-server.exe
9697
cd /tmp && zip -q $(PWD)/release/rtsp-simple-server_$(VERSION)_windows_amd64.zip rtsp-simple-server.exe
9798

98-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-simple-server
99+
GOOS=linux GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-simple-server
99100
tar -C /tmp -czf $(PWD)/release/rtsp-simple-server_$(VERSION)_linux_amd64.tar.gz --owner=0 --group=0 rtsp-simple-server
100101

101-
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD) -o /tmp/rtsp-simple-server
102+
GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD) -o /tmp/rtsp-simple-server
102103
tar -C /tmp -czf $(PWD)/release/rtsp-simple-server_$(VERSION)_linux_arm6.tar.gz --owner=0 --group=0 rtsp-simple-server
103104

104-
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GOBUILD) -o /tmp/rtsp-simple-server
105+
GOOS=linux GOARCH=arm GOARM=7 $(GOBUILD) -o /tmp/rtsp-simple-server
105106
tar -C /tmp -czf $(PWD)/release/rtsp-simple-server_$(VERSION)_linux_arm7.tar.gz --owner=0 --group=0 rtsp-simple-server
106107

107-
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -o /tmp/rtsp-simple-server
108+
GOOS=linux GOARCH=arm64 $(GOBUILD) -o /tmp/rtsp-simple-server
108109
tar -C /tmp -czf $(PWD)/release/rtsp-simple-server_$(VERSION)_linux_arm64.tar.gz --owner=0 --group=0 rtsp-simple-server
109110

110-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-simple-server
111+
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o /tmp/rtsp-simple-server
111112
tar -C /tmp -czf $(PWD)/release/rtsp-simple-server_$(VERSION)_darwin_amd64.tar.gz --owner=0 --group=0 rtsp-simple-server
112113

113-
define DOCKERFILE_TRAVIS
114-
FROM ruby:alpine
115-
RUN apk add --no-cache build-base git
116-
RUN gem install travis
114+
define DOCKERFILE_IMAGE
115+
FROM --platform=linux/amd64 $(BASE_IMAGE) AS build
116+
RUN apk add --no-cache git
117+
WORKDIR /s
118+
COPY go.mod go.sum ./
119+
RUN go mod download
120+
COPY . ./
121+
ARG VERSION
122+
ARG OPTS
123+
RUN export CGO_ENABLED=0 $${OPTS} \
124+
&& go build -ldflags "-X main.Version=$$VERSION" -o /rtsp-simple-server
125+
126+
FROM scratch
127+
COPY --from=build /rtsp-simple-server /rtsp-simple-server
128+
ENTRYPOINT [ "/rtsp-simple-server"]
117129
endef
118-
export DOCKERFILE_TRAVIS
130+
export DOCKERFILE_IMAGE
119131

120-
travis-setup:
121-
echo "$$DOCKERFILE_TRAVIS" | docker build - -t temp
122-
docker run --rm -it \
123-
-v $(PWD):/s \
124-
temp \
125-
sh -c "cd /s \
126-
&& travis setup releases --force"
132+
dockerhub:
133+
$(eval export DOCKER_CLI_EXPERIMENTAL=enabled)
134+
$(eval VERSION := $(shell git describe --tags))
135+
136+
docker buildx rm test 2>/dev/null || true
137+
docker buildx create --name=builder --use
138+
139+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
140+
--push -t aler9/rtsp-simple-server:$(VERSION)-amd64 --build-arg OPTS="GOOS=linux GOARCH=amd64" --platform=linux/amd64
141+
142+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
143+
--push -t aler9/rtsp-simple-server:$(VERSION)-armv6 --build-arg OPTS="GOOS=linux GOARCH=arm GOARM=6" --platform=linux/arm/v6
144+
145+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
146+
--push -t aler9/rtsp-simple-server:$(VERSION)-armv7 --build-arg OPTS="GOOS=linux GOARCH=arm GOARM=7" --platform=linux/arm/v7
147+
148+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
149+
--push -t aler9/rtsp-simple-server:$(VERSION)-arm64 --build-arg OPTS="GOOS=linux GOARCH=arm64" --platform=linux/arm64/v8
150+
151+
docker manifest create --amend aler9/rtsp-simple-server:$(VERSION) \
152+
$(foreach ARCH,amd64 armv6 armv7 arm64,aler9/rtsp-simple-server:$(VERSION)-$(ARCH))
153+
docker manifest push aler9/rtsp-simple-server:$(VERSION)
154+
155+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
156+
--push -t aler9/rtsp-simple-server:latest-amd64 --build-arg OPTS="GOOS=linux GOARCH=amd64" --platform=linux/amd64
157+
158+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
159+
--push -t aler9/rtsp-simple-server:latest-armv6 --build-arg OPTS="GOOS=linux GOARCH=arm GOARM=6" --platform=linux/arm/v6
160+
161+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
162+
--push -t aler9/rtsp-simple-server:latest-armv7 --build-arg OPTS="GOOS=linux GOARCH=arm GOARM=7" --platform=linux/arm/v7
163+
164+
echo "$$DOCKERFILE_IMAGE" | docker buildx build . -f - --build-arg VERSION=$(VERSION) \
165+
--push -t aler9/rtsp-simple-server:latest-arm64 --build-arg OPTS="GOOS=linux GOARCH=arm64" --platform=linux/arm64/v8
166+
167+
docker manifest create --amend aler9/rtsp-simple-server:latest \
168+
$(foreach ARCH,amd64 armv6 armv7 arm64,aler9/rtsp-simple-server:latest-$(ARCH))
169+
docker manifest push aler9/rtsp-simple-server:latest
170+
171+
docker buildx rm builder

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
[![Go Report Card](https://goreportcard.com/badge/github.com/aler9/rtsp-simple-server)](https://goreportcard.com/report/github.com/aler9/rtsp-simple-server)
55
[![Build Status](https://travis-ci.org/aler9/rtsp-simple-server.svg?branch=master)](https://travis-ci.org/aler9/rtsp-simple-server)
6+
[![Docker Hub](https://img.shields.io/badge/docker-aler9%2Frtsp--simple--proxy-blue)](https://hub.docker.com/r/aler9/rtsp-simple-server)
67

78
_rtsp-simple-server_ is a simple, ready-to-use and zero-dependency RTSP server, a software that allows multiple users to publish and read live video and audio streams. RTSP is a standardized protocol that defines how to perform these operations with the help of a server, that is contacted by both readers and publishers in order to negotiate a streaming protocol. The server is then responsible of relaying the publisher streams to the readers.
89

@@ -48,7 +49,19 @@ Features:
4849

4950
## Advanced usage and FAQs
5051

51-
#### Setup publisher authentication
52+
#### Usage with Docker
53+
54+
Download and launch the image:
55+
```
56+
docker run --rm -it --network=host aler9/rtsp-simple-server
57+
```
58+
59+
The `--network=host` argument is mandatory since Docker can change the source port of UDP packets for routing reasons, and this makes RTSP routing impossible. An alternative consists in disabling UDP and exposing the RTSP port:
60+
```
61+
docker run --rm -it -p 8554 aler9/rtsp-simple-server --protocols=tcp
62+
```
63+
64+
#### Publisher authentication
5265

5366
Start the server and set a username and a password:
5467
```

0 commit comments

Comments
 (0)