dongyu3967 2019-08-13 11:40
浏览 76

CircleCI与Bitbucket Go构建问题

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.

  • 写回答

2条回答 默认 最新

  • douxie7339 2019-08-19 12:04
    关注

    This issue might be related.

    Setting CGO_ENABLED=0 on alpine might solve it unless it is required by your build. The line to add could be like: export CGO_ENABLED=0

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)