Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
FROM golang:1.14.1 as delve

RUN curl --location --output delve-1.4.0.tar.gz https://github.com/go-delve/delve/archive/v1.4.0.tar.gz \
&& tar xzf delve-1.4.0.tar.gz
&& tar xzf delve-1.4.0.tar.gz \
&& mv delve-1.4.0 delve-source
Comment thread
loosebazooka marked this conversation as resolved.

# Patch delve to change default for --only-same-user to false
# Required as `kubectl port-forward` to dlv port is refused.
# We must install patch(1) to apply the patch.
COPY delve-only-same-user.patch .
RUN apt-get update && apt-get install -y --no-install-recommends \
patch \
&& patch -p0 < delve-only-same-user.patch
&& patch -p0 -d delve-source < delve-only-same-user.patch

# Produce an as-static-as-possible dlv binary to work on musl and glibc
RUN cd delve-1.4.0 && CGO_ENABLED=0 go build -o /go/dlv -ldflags '-s -w -extldflags "-static"' ./cmd/dlv/
RUN cd delve-source && CGO_ENABLED=0 go build -o /go/dlv -ldflags '-s -w -extldflags "-static"' ./cmd/dlv/

# Now populate the duct-tape image with the language runtime debugging support files
# The debian image is about 95MB bigger
Expand Down
12 changes: 8 additions & 4 deletions go/delve-only-same-user.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
diff --git delve-1.4.0/cmd/dlv/cmds/commands.go delve-1.4.0/cmd/dlv/cmds/commands.go
index 0a17860..7e46206 100644
--- delve-1.4.0/cmd/dlv/cmds/commands.go
+++ delve-1.4.0/cmd/dlv/cmds/commands.go
Patch delve to default --only-same-user to false [1].
Required as connections proxied via `kubectl port-forward` come from
the outside of the pod, and so connecting to the dlv port is refused.

[1] https://github.com/go-delve/delve/pull/1764

--- cmd/dlv/cmds/commands.go
+++ cmd/dlv/cmds/commands.go
@@ -114,7 +114,7 @@ func New(docCall bool) *cobra.Command {
RootCommand.PersistentFlags().StringVar(&BuildFlags, "build-flags", buildFlagsDefault, "Build flags, to be passed to the compiler.")
RootCommand.PersistentFlags().StringVar(&WorkingDir, "wd", ".", "Working directory for running the program.")
Expand Down