Failing to build from Dockerfile

Trying to build k6 image from Dockerfile provided in k6 github, receiveing

=> CACHED [builder 4/5] RUN apk --no-cache add git                                                                                                     0.0s
 => ERROR [builder 5/5] RUN CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X$(date -u +"%FT%T%z")/$(git  0.2s
 > [builder 5/5] RUN CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X$(date -u +"%FT%T%z")/$(git describe --always --long --dirty)":
#12 0.150 fatal: not a git repository (or any of the parent directories): .git
#12 0.152 go: go.mod file not found in current directory or any parent directory; see 'go help modules'
executor failed running [/bin/sh -c CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X$(date -u +"%FT%T%z")/$(git describe --always --long --dirty)"]: exit code: 1

I guess that’s because there are no repositories @, probably due to the fact you switched to grafana/k6 github (Congratz on that!). Could you please provide new URL or help to configure that Dockerfile of yours so it works (if ‘wrong’ URL isn’t the case)?:slight_smile:
Thank you a ton in advance, been enjoying using k6 so far.

Hi there, is a Go vanity URL that currently redirects to, which then GitHub redirects to We should update the redirect of the vanity URL, but in practice this should have no impact for importing the package or building the Docker image. I tested building it from master and it works fine for me.

That error message indicates you’re trying to build the image from just source files (and no go.mod?) and not the k6 Git repo, which is needed for the git describe command we use to embed the Git information in the version string. Or you’re building from the wrong directory, passing an incorrect context to Docker. Some more information about your environment and the commands you’re running would help troubleshoot this.

Hey, thank you for your response.
Could you please provide the command you used to build from master?
I’ve tried to do the same, cloned master branch and tried to build, that just didn’t work out. Mayhap I’m doing something terribly wrong there:(
Also I do have go.mod, go.sum and such. Yes, I’ve tried to build directly from Dockerfile, implying all paths are there sudo docker build -< Dockerfile (after cloning master branch)

UPD. Solved by docker build .

Glad you solved it.

The syntax you were using before pipes the Dockerfile via stdin, but no build context is uploaded, so the build directory was empty.

1 Like

Always silly mistakes, yet thank you for navigating to the source of the problem:)