goreleaser: Invalid binary for alpine amd64 (x86_64)

Host machine:

$ uname -a
Darwin MacBook-Pro.beeline 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64

golang:alpine

$ docker run --rm golang:alpine uname -a
Linux 0e0a30d12b5b 4.9.13-moby #1 SMP Sat Mar 25 02:48:44 UTC 2017 x86_64 Linux

$ docker run --rm golang:alpine go version
go version go1.8.1 linux/amd64

golang:latest

$ docker run --rm golang:latest uname -a
Linux f912eb34c93b 4.9.13-moby #1 SMP Sat Mar 25 02:48:44 UTC 2017 x86_64 GNU/Linux

$ docker run --rm golang:latest go version
go version go1.8.1 linux/amd64

The problem:

$ docker run --rm golang:alpine \
  /bin/sh -c 'apk update --no-cache \
           && apk add --no-cache ca-certificates git wget \
           && update-ca-certificates &>/dev/null \
           && wget -q -O /tmp/goreleaser.tar.gz \
              https://github.com/goreleaser/goreleaser/releases/download/v0.17.1/goreleaser_Linux_x86_64.tar.gz \
           && mkdir /tmp/goreleaser && tar xf /tmp/goreleaser.tar.gz -C /tmp/goreleaser \
           && /tmp/goreleaser/goreleaser --version'
...
/bin/sh: /tmp/goreleaser/goreleaser: not found
$ docker run --rm golang:latest \
  /bin/sh -c 'wget -q -O /tmp/goreleaser.tar.gz \
              https://github.com/goreleaser/goreleaser/releases/download/v0.17.1/goreleaser_Linux_x86_64.tar.gz \
           && mkdir /tmp/goreleaser && tar xf /tmp/goreleaser.tar.gz -C /tmp/goreleaser \
           && /tmp/goreleaser/goreleaser --version'
...
goreleaser version 0.17.1, commit 5b06bef0666fd105b65a41d53d45e2d9db6e4862, built at 2017-05-02T22:24:02Z

$ docker run --rm golang:latest \
  /bin/sh -c 'wget -q -O /tmp/goreleaser.tar.gz \
              https://github.com/goreleaser/goreleaser/releases/download/v0.17.1/goreleaser_Linux_x86_64.tar.gz \
           && mkdir /tmp/goreleaser && tar xf /tmp/goreleaser.tar.gz -C /tmp/goreleaser \
           && readelf -l /tmp/goreleaser/goreleaser | grep "program interpreter"'
...
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

The reason is that /lib64/ld-linux-x86-64.so.2 doesn’t exist at alpine linux.

So, if I get 32bit app for alpine, then it is ok

$ docker run --rm golang:alpine \
  /bin/sh -c 'apk update --no-cache \
           && apk add --no-cache ca-certificates git wget \
           && update-ca-certificates &>/dev/null \
           && wget -q -O /tmp/goreleaser.tar.gz \
              https://github.com/goreleaser/goreleaser/releases/download/v0.17.1/goreleaser_Linux_i386.tar.gz \
           && mkdir /tmp/goreleaser && tar xf /tmp/goreleaser.tar.gz -C /tmp/goreleaser \
           && /tmp/goreleaser/goreleaser --version'
...
goreleaser version 0.17.1, commit 5b06bef0666fd105b65a41d53d45e2d9db6e4862, built at 2017-05-02T22:24:02Z

$ docker run --rm golang:alpine \
  /bin/sh -c 'apk update --no-cache \
           && apk add --no-cache ca-certificates git \
           && go get -d github.com/goreleaser/goreleaser \
           && cd /go/src/github.com/goreleaser/goreleaser \
           && git checkout v0.17.1 \
           && go install . \
           && goreleaser --version'
...
goreleaser version dev, commit none, built at unknown

So, could you also build binary for alpine ?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (19 by maintainers)

Commits related to this issue

Most upvoted comments

yes, works fine! thanks a lot!

I think I get it:

  • CGO is disabled by default when cross-compiling
  • travis is linux amd64, so CGO is not disabled in that case - because it is not cross-compiling
  • alpine is also a linux amd64, but has fewer libs etc, and with CGO enabled, the binary probably rely in some of them

Hopefully PR #232 will fix this problem!