Dash-Industry-Forum / livesim2

DASH Live Source Simulator v2 in Go
Other
34 stars 5 forks source link

Error building livesim2 in docker: 'no matching versions for query "latest"' #105

Closed wschidol closed 9 months ago

wschidol commented 9 months ago

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

github.com/Dash-Industry-Forum/livesim2/cmd/dashfetcher/app: no matching versions for query "latest"

(see a fuller log below).

Can you tell what is going wrong?

Step 14/16 : RUN /usr/local/go/bin/go mod tidy
 ---> Running in 7aa1ebdab436
go: downloading github.com/Eyevinn/mp4ff v0.36.0
go: downloading github.com/stretchr/testify v1.8.4
go: downloading github.com/Comcast/gots v1.0.4
go: downloading github.com/rs/zerolog v1.29.1
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/Eyevinn/dash-mpd v0.10.0
go: downloading github.com/caddyserver/certmagic v0.19.1
go: downloading github.com/go-chi/chi/v5 v5.0.8
go: downloading github.com/knadh/koanf v1.5.0
go: downloading github.com/prometheus/client_golang v1.15.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df
go: downloading github.com/klauspost/cpuid/v2 v2.2.5
go: downloading github.com/libdns/libdns v0.2.1
go: downloading github.com/mholt/acmez v1.2.0
go: downloading github.com/miekg/dns v1.1.55
go: downloading github.com/zeebo/blake3 v0.2.3
go: downloading go.uber.org/zap v1.24.0
go: downloading golang.org/x/crypto v0.10.0
go: downloading golang.org/x/net v0.11.0
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/fsnotify/fsnotify v1.6.0
go: downloading github.com/fatih/structs v1.1.0
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading aqwari.net/xml v0.0.0-20210331023308-d9421b293817
go: downloading github.com/google/go-cmp v0.5.9
go: downloading github.com/go-test/deep v1.0.8
go: downloading github.com/coreos/go-systemd/v22 v22.5.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.2.0
go: downloading github.com/prometheus/client_model v0.4.0
go: downloading github.com/prometheus/common v0.44.0
go: downloading github.com/prometheus/procfs v0.10.1
go: downloading golang.org/x/sys v0.9.0
go: downloading google.golang.org/protobuf v1.30.0
go: downloading github.com/golang/protobuf v1.5.3
go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
go: downloading golang.org/x/tools v0.10.0
go: downloading golang.org/x/sync v0.3.0
go: downloading github.com/zeebo/assert v1.1.0
go: downloading go.uber.org/atomic v1.11.0
go: downloading go.uber.org/multierr v1.11.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading go.uber.org/goleak v1.1.11
go: downloading golang.org/x/text v0.10.0
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/joho/godotenv v1.3.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/hjson/hjson-go/v4 v4.0.0
go: downloading github.com/pelletier/go-toml v1.7.0
go: downloading github.com/mattn/go-isatty v0.0.19
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.4
go: downloading github.com/kr/pretty v0.3.1
go: downloading github.com/benbjohnson/clock v1.1.0
go: downloading github.com/kr/text v0.1.0
go: downloading github.com/rogpeppe/go-internal v1.10.0
go: downloading golang.org/x/mod v0.11.0
go: downloading github.com/zeebo/pcg v1.0.1
go: finding module for package github.com/Dash-Industry-Forum/livesim2/pkg/scte35
go: finding module for package github.com/Dash-Industry-Forum/livesim2/internal
go: finding module for package github.com/Dash-Industry-Forum/livesim2/cmd/dashfetcher/app
go: finding module for package github.com/Dash-Industry-Forum/livesim2/pkg/logging
go: finding module for package github.com/Dash-Industry-Forum/livesim2/cmd/livesim2/app
go: github.com/Dash-Industry-Forum/livesim2/dashfetcher imports
        github.com/Dash-Industry-Forum/livesim2/cmd/dashfetcher/app: no matching versions for query "latest"
go: github.com/Dash-Industry-Forum/livesim2/dashfetcher imports
        github.com/Dash-Industry-Forum/livesim2/internal: no matching versions for query "latest"
go: github.com/Dash-Industry-Forum/livesim2/dashfetcher imports
        github.com/Dash-Industry-Forum/livesim2/pkg/logging: no matching versions for query "latest"
go: github.com/Dash-Industry-Forum/livesim2/livesim2 imports
        github.com/Dash-Industry-Forum/livesim2/cmd/livesim2/app: no matching versions for query "latest"
go: github.com/Dash-Industry-Forum/livesim2/livesim2/app imports
        github.com/Dash-Industry-Forum/livesim2/pkg/scte35: no matching versions for query "latest"
The command '/bin/sh -c /usr/local/go/bin/go mod tidy' returned a non-zero code: 1
tobbee commented 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.

Dockerfile.txt

tobbee commented 9 months ago

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"]

Dockerfile.txt

tobbee commented 9 months ago

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

wschidol commented 9 months ago

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!

tobbee commented 9 months ago

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.