1 # Use base golang image from Docker Hub
2 FROM golang:1.12.7 as builder
4 # Download the dlv (delve) debugger for go (you can comment this out if unused)
5 RUN go get -u -v github.com/go-delve/delve/cmd/dlv
7 WORKDIR /src/prom-kafka-writer
9 RUN mkdir /librdkafka-dir && cd /librdkafka-dir
10 RUN git clone https://github.com/edenhill/librdkafka.git && \
12 ./configure --prefix /usr && \
16 # Install dependencies in go.mod and go.sum
20 # Copy rest of the application source code
23 # Compile the application to /app.
24 RUN go build -o ./bin/prom-kafka-writer -v ./cmd/prom-kafka-writer
26 # If you want to use the debugger, you need to modify the entrypoint to the
27 # container and point it to the "dlv debug" command:
28 # * UNCOMMENT the following ENTRYPOINT statement,
29 # * COMMENT OUT the last ENTRYPOINT statement
30 # Start the "dlv debug" server on port 3000 of the container.
31 #ENTRYPOINT ["dlv", "exec", "./bin/prom-kafka-writer", "--continue", "--accept-multiclient", "--api-version=2", "--headless", "--listen=:3000", "--log"]
33 # If you want to run WITHOUT the debugging server:
34 # * COMMENT OUT the previous ENTRYPOINT statements,
35 # * UNCOMMENT the following ENTRYPOINT statement.
39 COPY --from=builder /usr/lib/pkgconfig /usr/lib/pkgconfig
40 COPY --from=builder /usr/lib/librdkafka* /usr/lib/
41 COPY --from=builder //src/prom-kafka-writer/* /prom-kafka-writer/
42 WORKDIR /prom-kafka-writer
43 ENTRYPOINT ["./bin/prom-kafka-writer"]