Closed wschidol closed 9 months ago
Hi @wschidol,
I'm no expert on Docker, but it seems that you have messed up the directory structure of the livesim2 folder when copying files and dirs. It is the files of livesim2 that "go mod tidy" struggles with.
For the makefile to work properly, the git information about tags is also needed, so I think it is best to copy the whole livesim2 repo recursively.
There were also some issues with your Dockerfile in what paths were used for the resulting binaries and for vodroot.
I made some updates to your Dockerfile and ran it with livesim2 as a Directory one level below and it worked to build the image. I haven't run it, though.
One small detail that I should fix in the README is that you can run "go mod vendor" instead of "go mod tidy" in later versions of go. The former will now create and use the vendor catalogue, while the latter will not use the catalogue, but the cache directly.
I hope this makes you progress. In many cases, a Dockerimage of livesim2 is not needed since it is anyway one single binary. This is how it is run on https://livesim2.dashif.org, and how it is described in linode setup on the Wiki.
I just realised that the the ENTRYPOINT at the end of the Dockerfile was wrong. It should be something like
ENTRYPOINT ["/home/user/out/livesim2","--vodroot=/home/user/cmd/livesim2/app/testdata/assets"]
Another thought, livesim2, like other Go programs, is just a single binary, it is essentially only one file that needs to be added to the docker container. To achieve that, one can use a two-stage approach where one docker container builds the binary, and the second one contains it. A quick search returned this link with such an approach: https://medium.com/geekculture/optimizing-golang-docker-images-with-multi-stage-builds-ca7b305faa
Thanks @tobbee , I was able to get the Dockerfile to build by cloning the repo inside docker. Not sure what was wrong with the COPY command. Once I had the build working, I moved on to create a dockerfile with just the final executable in it, and after adapting the ENTRYPOINT I could run this inside docker. Nice!
Great that you succeeded. At some stage, I will probably add a Dockerfile to the repo to make it simple to build ones own docker image.
I am trying to build the livesim2 app v0.8.0 in docker, using go version 1.21. I am using the following Dockerfile:
Dockerfile.txt
The "go mod tidy" step fails with errors of the sort
(see a fuller log below).
Can you tell what is going wrong?