constabulary / gb

gb, the project based build tool for Go
https://getgb.io/
MIT License
2.15k stars 150 forks source link

Can't build project in Docker #731

Closed garrickstapleszed closed 6 years ago

garrickstapleszed commented 6 years ago

Hi all, I'm trying to use the 'private_s3_httpd' project. It is already set up to use gb. I can build it fine locally on Linux or OSX, but I get linking errors in Docker. Any suggestions on how to make this work?

Step 13/19 : RUN apk --no-cache add --virtual build-dependencies gcc musl-dev go git     && export GOPATH=/go     && export PATH=/go/bin:$PATH     && export CGO_ENABLED=0     && mkdir /go     && chmod -R 777 /go     && go get github.com/constabulary/gb/...     && git clone https://github.com/jehiah/private_s3_httpd.git     && cd private_s3_httpd     && go version     && ./vendor.sh && gb env && gb build     && mv bin/private_s3_httpd /usr/bin/private_s3_httpd     && apk del --purge -r build-dependencies     && rm -rf /go
 ---> Running in 27e19d0e5580
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/17) Installing binutils-libs (2.28-r3)
(2/17) Installing binutils (2.28-r3)
(3/17) Installing gmp (6.1.2-r1)
(4/17) Installing isl (0.18-r0)
(5/17) Installing libgomp (6.4.0-r5)
(6/17) Installing libatomic (6.4.0-r5)
(7/17) Installing libgcc (6.4.0-r5)
(8/17) Installing mpfr3 (3.1.5-r1)
(9/17) Installing mpc1 (1.0.3-r1)
(10/17) Installing libstdc++ (6.4.0-r5)
(11/17) Installing gcc (6.4.0-r5)
(12/17) Installing musl-dev (1.1.18-r2)
(13/17) Installing go (1.9.2-r1)
(14/17) Installing expat (2.2.5-r0)
(15/17) Installing pcre2 (10.30-r0)
(16/17) Installing git (2.15.0-r1)
(17/17) Installing build-dependencies (0)
Executing busybox-1.27.2-r7.trigger
OK: 316 MiB in 40 packages
Cloning into 'private_s3_httpd'...
go version go1.9.2 linux/amd64
GB_PROJECT_DIR="/private_s3_httpd"
GB_SRC_PATH="/private_s3_httpd/src:/private_s3_httpd/vendor/src"
GB_PKG_DIR="/private_s3_httpd/pkg/linux-amd64"
GB_BIN_SUFFIX="-linux-amd64"
GB_GOROOT="/usr/lib/go"
github.com/aws/aws-sdk-go/aws/client/metadata
github.com/aws/aws-sdk-go/internal/shareddefaults
github.com/aws/aws-sdk-go/aws/awserr
github.com/gorilla/handlers
github.com/jmespath/go-jmespath
github.com/go-ini/ini
github.com/aws/aws-sdk-go/aws/awsutil
github.com/aws/aws-sdk-go/aws/credentials
github.com/aws/aws-sdk-go/aws/endpoints
github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/request
github.com/aws/aws-sdk-go/private/protocol
github.com/aws/aws-sdk-go/private/protocol/query/queryutil
github.com/aws/aws-sdk-go/aws/client
github.com/aws/aws-sdk-go/aws/corehandlers
github.com/aws/aws-sdk-go/private/protocol/rest
github.com/aws/aws-sdk-go/aws/credentials/endpointcreds
github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
github.com/aws/aws-sdk-go/aws/ec2metadata
github.com/aws/aws-sdk-go/aws/signer/v4
github.com/aws/aws-sdk-go/private/protocol/query
github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds
github.com/aws/aws-sdk-go/private/protocol/restxml
github.com/aws/aws-sdk-go/aws/defaults
github.com/aws/aws-sdk-go/service/sts
github.com/aws/aws-sdk-go/aws/credentials/stscreds
github.com/aws/aws-sdk-go/aws/session
github.com/aws/aws-sdk-go/service/s3
2018/01/16 18:45:36 cannot handle R_TLS_IE (sym sync/atomic.(*Value).Store) when linking internally
cmd/private_s3_httpd
# cmd/private_s3_httpd
FATAL: command "build" failed: exit status 1
The command '/bin/sh -c apk --no-cache add --virtual build-dependencies gcc musl-dev go git     && export GOPATH=/go     && export PATH=/go/bin:$PATH     && export CGO_ENABLED=0     && mkdir /go     && chmod -R 777 /go     && go get github.com/constabulary/gb/...     && git clone https://github.com/jehiah/private_s3_httpd.git     && cd private_s3_httpd     && go version     && ./vendor.sh && gb env && gb build     && mv bin/private_s3_httpd /usr/bin/private_s3_httpd     && apk del --purge -r build-dependencies     && rm -rf /go' returned a non-zero code: 1
tianon commented 6 years ago

It looks like you're using an Alpine-based container (apk add ...) -- does the software you're looking to build support Alpine? Have you got a very minimal Dockerfile which can reproduce the issue (what you've posted appears to be Step 13 of 19, and it's a long one, so doesn't seem very minimal)?

For my own gb projects, I use gb installed on my host to manage the project and build outside of Docker, but once I go to build inside Docker, I use GOPATH=/project/path:/project/path/vendor to simply use native go build/go install within Docker (since I don't need gb's additional functionality within the container -- I just need my code compiled into a usable binary).

garrickstapleszed commented 6 years ago

Thank you for the reply. I'm happy to say that just changing from alpine:3.8 to golang:alpine fixed my problem. I guess private_s3_httpd doesn't like alpine's tiny libc; it needs the full glibc.