2019-03-31 14:52
浏览 60

为什么参加考试突然需要“ gcc”?

I have a project that I upgraded FROM golang:1.9-alpine to FROM golang:1.12-alpine and now my test aren't running. It's now saying:

$ docker-compose exec bot go vet       
# runtime/cgo
exec: "gcc": executable file not found in $PATH

According to the docs for this is the compiler. How come I can run my app without this but it won't run tests without it? I've been looking through the change logs and must be missing where this is covered.

Here's my Dockerfile:

FROM golang:1.12-alpine
RUN mkdir /app
ADD src/ /app

# Fetch application dependencies
RUN apk add --no-cache --update git \
    && go get \
    && go get \
    && go get \
    && apk del git

# Build binary
RUN go build -o main .

CMD ["/app/main"]
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongzhang1864 2019-03-31 15:11

    It looks like you're encountering this issue:

    The workaround suggested is to set these environment variables when building:


    You might also prefer a multi-stage docker build, so that your final docker image is minimal (for example, not including the source files you've compiled from, and the go compiler). An example from the docker documentation is here:

    解决 无用
    打赏 举报

相关推荐 更多相似问题