Reputation:
I use Docker to add my project to it, now I want to run some test on it and I got errors that the test failed
Any idea what I miss here?
# build stage
FROM golang:1.11.1-alpine3.8 AS builder
RUN apk add --update --no-cache make \
git
ADD https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
RUN mkdir -p $GOPATH/src/github.company/user/go-application
WORKDIR $GOPATH/src/github.company/user/go-application
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only
COPY . ./
Now I build the docker which finish successfully and now I want to run tests on it.
I did docker run docker run -it goapp
which run successfully
And now I use command go test -v ./...
and I got error
# runtime/cgo
exec: "gcc": executable file not found in $PATH
FAIL github.company/user/go-application [build failed]
FAIL github.company/user/go-application/integration [build failed]
Any idea how to resolve this ?
I try another step in docker file like following which doesnt helps
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /go-application .
Upvotes: 10
Views: 13912
Reputation: 79674
You've disabled CGO for your build, but you're not disabling CGO for your tests, which you must do:
CGO_ENABLED=0 GOOS=linux go test -v ./...
Upvotes: 17