#StackBounty: #go #circleci #alpine #bitbucket-cli CircleCI vs Bitbucket Go Build Issue

Bounty: 50

I’m running a go build command on a golang:1.11-alpine on two separate CI tools. As you can see the commands are exactly the same and the docker image is exactly the same.

For some reason, when I run the compiled executable on an alpine:3.9 docker image, only the bitbucket runs.

For the Circle CI build, I get the following error:

standard_init_linux.go:207: exec user process caused “exec format error”

I was reading online that it might be an architecture issue so I did a file <file> in the terminal and it appears both were compiled the same way. Here is the response I received for both files (identical):

cloud: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped

Circle CI

docker:
  - image: golang:1.11-alpine

steps:
  - checkout
  - run:
      name: Build Go Server
      command: |
        apk add --no-cache git build-base
        export GOPATH="$HOME/go"
        export PATH="$PATH:$GOPATH/bin"
        go get -u github.com/golang/lint/golint@v0.0.0-20190227174305-8f45f776aaf1
        go mod vendor
        golint -set_exit_status $(go list ./... | grep -v /vendor/)
        go test -short $(go list ./... | grep -v /vendor/)
        go build -ldflags="-s -w"

Bitbucket CI

steps:
    - step: &step-test-and-build-go
            name: Test and Build Go Server
            image: golang:1.11-alpine
            script:
                - apk add --no-cache git build-base
                - export GOPATH="$HOME/go"
                - export PATH="$PATH:$GOPATH/bin"
                - go get -u github.com/golang/lint/golint@v0.0.0-20190227174305-8f45f776aaf1
                - go mod vendor
                - golint -set_exit_status $(go list ./... | grep -v /vendor/)
                - go test -short $(go list ./... | grep -v /vendor/)
                - go build -ldflags="-s -w"

Circle CI go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/project/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build122963699=/tmp/go-build -gno-record-gcc-switches"

Bitbucket CI go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/opt/atlassian/pipelines/agent/build/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build179086021=/tmp/go-build -gno-record-gcc-switches"

I have cross-posted this question to the CircleCI forum.


Get this bounty!!!