@ -1,7 +1,7 @@
@@ -1,7 +1,7 @@
.PHONY : $( shell ls )
BASE_IMAGE = amd64/ golang:1.14-alpine3.11
BASE_IMAGE = golang:1.14-alpine3.11
help :
@echo "usage: make [action]"
@ -13,7 +13,7 @@ help:
@@ -13,7 +13,7 @@ help:
@echo " test run available tests"
@echo " run ARGS=args run app"
@echo " release build release assets"
@echo " travis-setup setup travis CI "
@echo " dockerhub build and push docker hub images "
@echo ""
blank :=
@ -23,15 +23,15 @@ $(blank)
@@ -23,15 +23,15 @@ $(blank)
e n d e f
mod-tidy :
docker run --rm -it -v $( PWD) :/s $( BASE_IMAGE) \
docker run --rm -it -v $( PWD) :/s amd64/ $( 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) \
docker run --rm -it -v $( PWD) :/s amd64/ $( BASE_IMAGE) \
sh -c "cd /s && find . -type f -name '*.go' | xargs gofmt -l -w -s"
d e f i n e D O C K E R F I L E _ T E S T
F R O M $( BASE_IMAGE )
F R O M a m d 6 4 / $( BASE_IMAGE )
R U N a p k a d d - - n o - c a c h e m a k e d o c k e r - c l i g i t
W O R K D I R / s
C O P Y g o . m o d g o . s u m . /
@ -48,13 +48,13 @@ test:
@@ -48,13 +48,13 @@ test:
make test-nodocker
test-nodocker :
$( eval export CGO_ENABLED = 0)
$( foreach IMG,$( shell echo test-images/*/ | xargs -n1 basename) , \
docker build -q test-images/$( IMG) -t rtsp-simple-server-test-$( IMG) $( NL) )
$( eval export CGO_ENABLED = 0)
go test -v .
d e f i n e D O C K E R F I L E _ R U N
F R O M $( BASE_IMAGE )
F R O M a m d 6 4 / $( BASE_IMAGE )
R U N a p k a d d - - n o - c a c h e g i t
W O R K D I R / s
C O P Y g o . m o d g o . s u m . /
@ -72,7 +72,7 @@ run:
@@ -72,7 +72,7 @@ run:
/out $( ARGS)
d e f i n e D O C K E R F I L E _ R E L E A S E
F R O M $( BASE_IMAGE )
F R O M a m d 6 4 / $( BASE_IMAGE )
R U N a p k a d d - - n o - c a c h e z i p m a k e g i t t a r
W O R K D I R / s
C O P Y g o . m o d g o . s u m . /
@ -88,39 +88,84 @@ release:
@@ -88,39 +88,84 @@ release:
temp sh -c "rm -rf /out/release && cp -r /s/release /out/"
release-nodocker :
$( eval export CGO_ENABLED = 0)
$( eval VERSION := $( shell git describe --tags) )
$( eval GOBUILD := go build -ldflags '-X " main.Version=$(VERSION)" ' )
$( eval GOBUILD := go build -ldflags '-X main.Version=$(VERSION)' )
rm -rf release && mkdir release
CGO_ENABLED = 0 GOOS = windows GOARCH = amd64 $( GOBUILD) -o /tmp/rtsp-simple-server.exe
GOOS = windows GOARCH = amd64 $( GOBUILD) -o /tmp/rtsp-simple-server.exe
cd /tmp && zip -q $( PWD) /release/rtsp-simple-server_$( VERSION) _windows_amd64.zip rtsp-simple-server.exe
CGO_ENABLED = 0 GOOS = linux GOARCH = amd64 $( GOBUILD) -o /tmp/rtsp-simple-server
GOOS = linux GOARCH = amd64 $( GOBUILD) -o /tmp/rtsp-simple-server
tar -C /tmp -czf $( PWD) /release/rtsp-simple-server_$( VERSION) _linux_amd64.tar.gz --owner= 0 --group= 0 rtsp-simple-server
CGO_ENABLED = 0 GOOS = linux GOARCH = arm GOARM = 6 $( GOBUILD) -o /tmp/rtsp-simple-server
GOOS = linux GOARCH = arm GOARM = 6 $( GOBUILD) -o /tmp/rtsp-simple-server
tar -C /tmp -czf $( PWD) /release/rtsp-simple-server_$( VERSION) _linux_arm6.tar.gz --owner= 0 --group= 0 rtsp-simple-server
CGO_ENABLED = 0 GOOS = linux GOARCH = arm GOARM = 7 $( GOBUILD) -o /tmp/rtsp-simple-server
GOOS = linux GOARCH = arm GOARM = 7 $( GOBUILD) -o /tmp/rtsp-simple-server
tar -C /tmp -czf $( PWD) /release/rtsp-simple-server_$( VERSION) _linux_arm7.tar.gz --owner= 0 --group= 0 rtsp-simple-server
CGO_ENABLED = 0 GOOS = linux GOARCH = arm64 $( GOBUILD) -o /tmp/rtsp-simple-server
GOOS = linux GOARCH = arm64 $( GOBUILD) -o /tmp/rtsp-simple-server
tar -C /tmp -czf $( PWD) /release/rtsp-simple-server_$( VERSION) _linux_arm64.tar.gz --owner= 0 --group= 0 rtsp-simple-server
CGO_ENABLED = 0 GOOS = darwin GOARCH = amd64 $( GOBUILD) -o /tmp/rtsp-simple-server
GOOS = darwin GOARCH = amd64 $( GOBUILD) -o /tmp/rtsp-simple-server
tar -C /tmp -czf $( PWD) /release/rtsp-simple-server_$( VERSION) _darwin_amd64.tar.gz --owner= 0 --group= 0 rtsp-simple-server
d e f i n e D O C K E R F I L E _ T R A V I S
FROM ruby : alpine
R U N a p k a d d - - n o - c a c h e b u i l d - b a s e g i t
R U N g e m i n s t a l l t r a v i s
d e f i n e D O C K E R F I L E _ I M A G E
F R O M --platform = linux/amd64 $( BASE_IMAGE) AS build
R U N a p k a d d - - n o - c a c h e g i t
W O R K D I R / s
C O P Y g o . m o d g o . s u m . /
R U N g o m o d d o w n l o a d
C O P Y . . /
A R G V E R S I O N
A R G O P T S
R U N export CGO_ENABLED = 0 $$ { OPTS} \
&& go build -ldflags " -X main.Version= $$ VERSION " -o /rtsp-simple-server
F R O M s c r a t c h
C O P Y --from = build /rtsp-simple-server /rtsp-simple-server
E N T R Y P O I N T [ "/rtsp-simple-server" ]
e n d e f
export DOCKERFILE_TRAVIS
export DOCKERFILE_IMAGE
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"
dockerhub :
$( eval export DOCKER_CLI_EXPERIMENTAL = enabled)
$( eval VERSION := $( shell git describe --tags) )
docker buildx rm test 2>/dev/null || true
docker buildx create --name= builder --use
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:$( VERSION) -amd64 --build-arg OPTS = "GOOS=linux GOARCH=amd64" --platform= linux/amd64
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:$( VERSION) -armv6 --build-arg OPTS = "GOOS=linux GOARCH=arm GOARM=6" --platform= linux/arm/v6
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:$( VERSION) -armv7 --build-arg OPTS = "GOOS=linux GOARCH=arm GOARM=7" --platform= linux/arm/v7
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:$( VERSION) -arm64 --build-arg OPTS = "GOOS=linux GOARCH=arm64" --platform= linux/arm64/v8
docker manifest create --amend aler9/rtsp-simple-server:$( VERSION) \
$( foreach ARCH,amd64 armv6 armv7 arm64,aler9/rtsp-simple-server:$( VERSION) -$( ARCH) )
docker manifest push aler9/rtsp-simple-server:$( VERSION)
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:latest-amd64 --build-arg OPTS = "GOOS=linux GOARCH=amd64" --platform= linux/amd64
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:latest-armv6 --build-arg OPTS = "GOOS=linux GOARCH=arm GOARM=6" --platform= linux/arm/v6
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:latest-armv7 --build-arg OPTS = "GOOS=linux GOARCH=arm GOARM=7" --platform= linux/arm/v7
echo " $$ DOCKERFILE_IMAGE " | docker buildx build . -f - --build-arg VERSION = $( VERSION) \
--push -t aler9/rtsp-simple-server:latest-arm64 --build-arg OPTS = "GOOS=linux GOARCH=arm64" --platform= linux/arm64/v8
docker manifest create --amend aler9/rtsp-simple-server:latest \
$( foreach ARCH,amd64 armv6 armv7 arm64,aler9/rtsp-simple-server:latest-$( ARCH) )
docker manifest push aler9/rtsp-simple-server:latest
docker buildx rm builder