From 02830e53b25c75a11ea09062910a4f64ea69c5fc Mon Sep 17 00:00:00 2001 From: skudasov Date: Mon, 16 Dec 2024 20:00:18 +0100 Subject: [PATCH] delve support --- GNUmakefile | 3 ++- plugins/chainlink.Dockerfile | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 592183923e2..f6409c7a056 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,6 +4,7 @@ COMMIT_SHA ?= $(shell git rev-parse HEAD) VERSION = $(shell jq -r '.version' package.json) GO_LDFLAGS := $(shell tools/bin/ldflags) GOFLAGS = -ldflags "$(GO_LDFLAGS)" +GCFLAGS = -gcflags "$(GO_GCFLAGS)" .PHONY: install install: install-chainlink-autoinstall ## Install chainlink and all its dependencies. @@ -38,7 +39,7 @@ docs: ## Install and run pkgsite to view Go docs .PHONY: install-chainlink install-chainlink: operator-ui ## Install the chainlink binary. - go install $(GOFLAGS) . + go install $(GCFLAGS) $(GOFLAGS) . .PHONY: install-chainlink-cover install-chainlink-cover: operator-ui ## Install the chainlink binary with cover flag. diff --git a/plugins/chainlink.Dockerfile b/plugins/chainlink.Dockerfile index a17f5df3898..cac5943b995 100644 --- a/plugins/chainlink.Dockerfile +++ b/plugins/chainlink.Dockerfile @@ -12,12 +12,18 @@ RUN go mod download # Env vars needed for chainlink build ARG COMMIT_SHA +# Flags for Go Delve debugger +ARG GO_GCFLAGS + COPY . . RUN apt-get update && apt-get install -y jq +# Install Delve for debugging +RUN go install github.com/go-delve/delve/cmd/dlv@latest + # Build the golang binaries -RUN make install-chainlink +RUN make GO_GCFLAGS="${GO_GCFLAGS}" install-chainlink # Install medianpoc binary RUN make install-medianpoc @@ -52,6 +58,7 @@ WORKDIR /chainlink-starknet/relayer COPY --from=buildgo /chainlink-starknet/relayer . RUN go install ./pkg/chainlink/cmd/chainlink-starknet + # Final image: ubuntu with chainlink binary FROM ubuntu:20.04 @@ -68,6 +75,8 @@ RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ COPY --from=buildgo /go/bin/chainlink /usr/local/bin/ COPY --from=buildgo /go/bin/chainlink-medianpoc /usr/local/bin/ COPY --from=buildgo /go/bin/chainlink-ocr3-capability /usr/local/bin/ +# Copy Delve debugger from build stage +COPY --from=buildgo /go/bin/dlv /usr/local/bin/dlv COPY --from=buildplugins /go/bin/chainlink-feeds /usr/local/bin/ ENV CL_MEDIAN_CMD chainlink-feeds @@ -92,6 +101,7 @@ ENV XDG_CACHE_HOME /home/${CHAINLINK_USER}/.cache RUN mkdir -p ${XDG_CACHE_HOME} EXPOSE 6688 +EXPOSE 40000 ENTRYPOINT ["chainlink"] HEALTHCHECK CMD curl -f http://localhost:6688/health || exit 1