diff --git a/GNUmakefile b/GNUmakefile index b765c63a3f4..a4377ab2009 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..883aa83c9cf 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 @@ -65,6 +72,9 @@ RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ && apt-get update && apt-get install -y postgresql-client-16 \ && apt-get clean all +# Copy Delve debugger from build stage +COPY --from=buildgo /go/bin/dlv /usr/local/bin/dlv + 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/