forked from DataDog/kafka-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
71 lines (59 loc) · 2.16 KB
/
Dockerfile
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
FROM ubuntu:22.04
# Install pre-reqs
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update >/dev/null
RUN apt install -y apt-utils jq build-essential unzip curl git pkg-config software-properties-common apt-transport-https ca-certificates >/dev/null
WORKDIR /root
# Install Go
RUN curl -sOL https://go.dev/dl/go1.17.5.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.17.5.linux-amd64.tar.gz
ENV PATH=$PATH:/usr/local/go/bin:/go/bin
ENV GOPATH=/go
# Install librdkafka
RUN curl -sL https://packages.confluent.io/deb/6.1/archive.key | apt-key add - 2>/dev/null
RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/6.1 stable main"
RUN apt-get update && apt-get install -y librdkafka1 librdkafka-dev >/dev/null
# Init repo.
WORKDIR /go/src/github.com/DataDog/kafka-kit
COPY tools.go tools.go
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
# Install protoc
RUN curl -sOL https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/protoc-3.19.1-linux-x86_64.zip
RUN unzip protoc-3.19.1-linux-x86_64.zip -d protoc
RUN mv protoc/bin/* /usr/local/bin/
RUN mv protoc/include/* /usr/local/include/
RUN rm -rf protoc*
# Install protoc / gRPC deps; these versions are managed in go.mod
RUN go get -d github.com/googleapis/googleapis
RUN go install \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
# Copy source.
COPY cmd cmd
COPY cluster cluster
COPY kafkaadmin kafkaadmin
COPY kafkametrics kafkametrics
COPY kafkazk kafkazk
COPY mapper mapper
COPY registry registry
# Codegen
RUN protoc -I ./registry -I $GOPATH/pkg/mod/$(awk '/googleapis/ {printf "%s@%s", $1, $2}' go.mod) \
--go_out ./registry \
--go_opt paths=source_relative \
--go-grpc_out ./registry \
--go-grpc_opt paths=source_relative \
--grpc-gateway_out ./registry \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt generate_unbound_methods=true \
registry/registry/registry.proto
# Build
RUN go install ./cmd/...
# Clean
RUN apt autoremove
RUN apt clean
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]