This build fails, however, as within the Docker container the mender-artifact binary is not created in /go/bin/ but in /go/src/github.com/mendersoftware/mender-artifact. Thus, the final command of the Makefile fails:
$ sudo make build-contained
rm -f mender-artifact && \
image_id=$(docker build -f Dockerfile . | awk '/Successfully built/{print $NF;}') && \
docker run --rm --entrypoint "/bin/sh" -v /mnt/hdd/github/bitbox-base-signing/mender-artifact:/binary $image_id -c "cp /go/bin/mender-artifact /binary" && \
docker image rm $image_id
cp: cannot stat '/go/bin/mender-artifact': No such file or directory
Makefile:62: recipe for target 'build-contained' failed
make: *** [build-contained] Error 1
Changing the cp command in this line within Makefile to the following, everything works out fine.
Hold on, there is something weird going on here. This has suddenly
started failing on our end too. But nothing has changed in
mender-artifact, so what happenedā¦?
Hej Lluis, just cloned master from scratch, but I still get the same issue:
$ sudo make build-contained
rm -f mender-artifact && \
image_id=$(docker build -f Dockerfile . | awk '/Successfully built/{print $NF;}') && \
docker run --rm --entrypoint "/bin/sh" -v /mnt/hdd/github/mender-artifact:/binary $image_id -c "cp /go/bin/mender-artifact /binary" && \
docker image rm $image_id
cp: cannot stat '/go/bin/mender-artifact': No such file or directory
Makefile:62: recipe for target 'build-contained' failed
make: *** [build-contained] Error 1
Breaking this down, here are the individual commands:
$ sudo docker build -f Dockerfile .
Sending build context to Docker daemon 11.24MB
Step 1/7 : FROM golang:1.11 as builder
---> 43a154fee764
Step 2/7 : RUN apt-get update && apt-get install -qyy liblzma-dev
---> Using cache
---> 68f45b8c31ae
Step 3/7 : RUN mkdir -p /go/src/github.com/mendersoftware/mender-artifact
---> Using cache
---> d337706800c9
Step 4/7 : WORKDIR /go/src/github.com/mendersoftware/mender-artifact
---> Using cache
---> 59cf5beb6c57
Step 5/7 : ADD ./ .
---> 361efd2c0875
Step 6/7 : RUN make build
---> Running in 0dd4ee5507e2
go build -ldflags "-X main.Version=3b729b4" -o mender-artifact cli/mender-artifact/artifacts.go cli/mender-artifact/copy.go cli/mender-artifact/log.go cli/mender-artifact/debugfs.go cli/mender-artifact/main.go cli/mender-artifact/partition.go cli/mender-artifact/sign.go cli/mender-artifact/read.go cli/mender-artifact/validate.go cli/mender-artifact/modify.go cli/mender-artifact/write.go cli/mender-artifact/dump.go
Removing intermediate container 0dd4ee5507e2
---> d09d6ff3e245
Step 7/7 : ENTRYPOINT [ "/go/src/github.com/mendersoftware/mender-artifact/mender-artifact" ]
---> Running in 13b6e54b5ed7
Removing intermediate container 13b6e54b5ed7
---> 11fdc9c62876
Successfully built 11fdc9c62876
$ sudo docker run --rm --entrypoint "/bin/sh" -v $(pwd):/binary 11fdc9c62876 -c "cp /go/bin/mender-artifact /binary"
cp: cannot stat '/go/bin/mender-artifact': No such file or directory
$ sudo docker run --rm --entrypoint "/bin/sh" -v $(pwd):/binary 11fdc9c62876 -c "cp /go/src/github.com/mendersoftware/mender-artifact/mender-artifact /binary"
The last command works and copies the mender-convert binary into the current directory. (note: I had to adapt $(shell pwd) to $(pwd) due to my use of zsh)
My bad, I miss-read your original report. I thought that you were affected by an error we saw this morning in our build system related to build-natives-contained target, not build-contained target as you actually reported. Funny that it is an independent error with a very similar error messageā¦
Anyway, I fixed now your issue and launched this new mender-artifact PR #222. It will be merged into master soon.