bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
12.15k stars 1.52k forks source link

docker build broken in golang container since v1.9.2 #3855

Open tmatth opened 2 weeks ago

tmatth commented 2 weeks ago

Which version are you using?

v1.9.2

Which operating system are you using?

Linux amd64 Docker

Describe how to replicate the issue

I'm assuming this is since #3409, but the build seems to be failing when run in a standard golang docker image.

To reproduce:

docker run -it golang:1.23.2-bullseye bash
curl -fSL http://github.com/aler9/rtsp-simple-server/archive/v1.9.2.tar.gz -o v1.9.2.tar.gz
tar -xzvf v1.9.2.tar.gz
cd mediamtx-1.9.2
go mod download -x
go generate ./...
2024/10/09 17:27:52 getting mediamtx version...
2024/10/09 17:27:52 ERR: repository does not exist
exit status 1
internal/core/core.go:37: running "go": exit status 1   <------------------------
2024/10/09 17:27:52 downloading hls.js v1.5.15...
2024/10/09 17:27:53 ok
2024/10/09 17:27:53 downloading mediamtx-rpicamera v2.3.2...
2024/10/09 17:27:54 ok
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o /tmp/rtsp-simple-server
internal/core/core.go:39:12: pattern VERSION: no matching files found

Server logs

No response

Network dump

No response

aler9 commented 2 weeks ago

Hello Tristan, the versiongetter script was introduced to automatically fill the version string inside the server, by using tag data inside the .git folder, an approach used by many other software.

Source code tarballs are automatically generated during every release and they do not include the .git folder nor any other data that might allow to extract the current version. My intention is to drop support for build processes that start from these tarballs. Your approach can be changed into:

FROM golang:1.23.2-bullseye
RUN git clone --depth=1 -b v1.9.2 http://github.com/bluenviron/mediamtx
WORKDIR mediamtx
RUN go generate ./...
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o /tmp/rtsp-simple-server

Let me know if you have a better solution.

tmatth commented 2 weeks ago

Hello Tristan, the versiongetter script was introduced to automatically fill the version string inside the server, by using tag data inside the .git folder, an approach used by many other software.

Source code tarballs are automatically generated during every release and they do not include the .git folder nor any other data that might allow to extract the current version. My intention is to drop support for build processes that start from these tarballs. Your approach can be changed into:

FROM golang:1.23.2-bullseye
RUN git clone --depth=1 -b v1.9.2 http://github.com/bluenviron/mediamtx
WORKDIR mediamtx
RUN go generate ./...
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o /tmp/rtsp-simple-server

Thanks that works around the issue for me.

Let me know if you have a better solution.

I'd suggest generating/including a VERSION file in release tarballs and just falling back to using git if its missing, this way you don't force a dependency on git for downstream users/packagers.