I am building a GO application dealing with Apache Pulsar. Go client requires C++ libraries, as asked by the Pulsar documentation (same thing for Kafka btw).
I want to package all this into a Container, the smallest possible. I usually use SCRATCH and copy the output from another golang based container. Unfortunately, I cannot get external libraries from this initial container:
FROM golang:latest as builder
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
ARG DOCKER_GIT_CREDENTIALS
WORKDIR /builder
ADD . /builder
RUN git config --global credential.helper store && echo "${DOCKER_GIT_CREDENTIALS}" > ~/.git-credentials
RUN make build
RUN echo $(go list -m) && mv bin/$(go list -m) app
FROM SCRATCH
COPY --from=builder /builder/app app
EXPOSE 8080
ENTRYPOINT ["./app"]
Using this make the build fail, looking for missing symbols
/go/pkg/mod/github.com/apache/pulsar/pulsar-client-go@v0.0.0-20200118070759-21660e9402f8/pulsar/client.go:29:9: undefined: newClient
...
while local build works.
How to properly integrate the libraries I need?