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