Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tmatth opened this issue Oct 9, 2024 · 2 comments
Open

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

tmatth opened this issue Oct 9, 2024 · 2 comments

Comments

@tmatth
Copy link
Contributor

tmatth commented Oct 9, 2024

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
Copy link
Member

aler9 commented Oct 9, 2024

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
Copy link
Contributor Author

tmatth commented Oct 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants