我正在尝试使用我的go应用程序创建一个docker映像。该应用程序(在MacOS上开发)取决于confluent-kafka- go哪个,而又取决于librdkafka-dev我在Docker映像中安装的对象,如下所示:
confluent-kafka- go
librdkafka-dev
FROM golang:1.1 RUN apt-get update RUN apt-get -y install librdkafka-dev VOLUME /workspace WORKDIR /workspace/src/my/app/folder ENTRYPOINT ["/bin/sh", "-c"]
我收到以下错误:
我/app/folder/vendor/github.com/confluentinc/confluent-kafka-go/kafka ../folder/vendor/github.com/confluentinc/confluent-kafka- go/kafka/00version.go:44:2:错误:#error“ confluent-kafka-go需要librdkafka v0.11.5或更高版本。从Confluent存储库中安装最新版本的librdkafka,请参阅http://docs.confluent.io/current/installation.html ”
据我了解, 已 安装最新版本。我该如何解决?
几周前我也遇到过类似的问题。IIRC confluent-kafka-go需要最新版本的librdkafka- dev,但尚未发布给高山或其他人。虽然我能够为ubuntu找到它,所以我的解决方案(它比我期望的要复杂得多,但它确实有效)是从干净的ubuntu开始,安装librdkafka- dev,安装我想要的Go版本并在docker中编译。
confluent-kafka-go
librdkafka- dev
外观如下:
FROM ubuntu # Install the C lib for kafka RUN apt-get update RUN apt-get install -y --no-install-recommends apt-utils wget gnupg software-properties-common RUN apt-get install -y apt-transport-https ca-certificates RUN wget -qO - https://packages.confluent.io/deb/5.1/archive.key | apt-key add - RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/5.1 stable main" RUN apt-get update RUN apt-get install -y librdkafka-dev # Install Go RUN add-apt-repository ppa:longsleep/golang-backports RUN apt-get update RUN apt-get install -y golang-1.11-go # build the library WORKDIR /go/src/gitlab.appsflyer.com/rantav/kafka-mirror-tester COPY *.go ./ COPY // the rest of your go files. You may copy recursive if you want COPY vendor vendor RUN GOPATH=/go GOOS=linux /usr/lib/go-1.11/bin/go build -a -o main . EXPOSE 8000 ENTRYPOINT ["./main"]