-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-debug
51 lines (48 loc) · 1.71 KB
/
Dockerfile-debug
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
FROM --platform=$BUILDPLATFORM rvolosatovs/protoc:4.0.0 as proto
WORKDIR /build
COPY pkg/proto pkg/proto
ENV PROTO_DIR pkg/proto
ENV PB_GO_PROTO_PATH pkg/pb
RUN mkdir -p pkg/pb
RUN find ${PROTO_DIR} -name '*.proto' -print0 | xargs -0 -n1 -I{} dirname {} | sort -u | \
while read -r dir; do \
pkg=${dir#${PROTO_DIR}/}; \
output_dir="${PB_GO_PROTO_PATH}/$pkg"; \
echo "Creating output directory: ${output_dir}"; \
mkdir -p ${output_dir}; \
echo "Compiling protobuf files in package: ${pkg}"; \
protoc \
--proto_path=${PROTO_DIR} \
--go_out=${PB_GO_PROTO_PATH} \
--go_opt=paths=source_relative \
--go-grpc_out=${PB_GO_PROTO_PATH} \
--go-grpc_opt=paths=source_relative \
${dir}/*.proto; \
done
FROM --platform=$BUILDPLATFORM golang:1.20-alpine as builder
ARG TARGETOS
ARG TARGETARCH
# Install delve
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Display GOPATH
RUN go env GOPATH
RUN echo $GOPATH
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=proto /build/pkg/pb pkg/pb
RUN env GOOS=$TARGETOS GOARCH=$TARGETARCH go build -gcflags="all=-N -l" -o extend-event-handler-go_$TARGETOS-$TARGETARCH
FROM alpine:3.19
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
#ADD data data
COPY --from=builder /build/extend-event-handler-go_$TARGETOS-$TARGETARCH extend-event-handler-go
COPY --from=builder /go/bin/dlv dlv
# Plugin arch gRPC server port
EXPOSE 6565
# Prometheus /metrics web server port
EXPOSE 8080
#CMD [ "/app/extend-grpc-event-handler" ]
CMD ["/app/dlv", "exec", "/app/extend-event-handler-go", "--headless", "--continue", "--accept-multiclient", "--api-version=2", "--listen=:40001"]