Skip to content

Commit 0596ba5

Browse files
authored
Simplify updating Go/Delve image (#40)
1 parent 4195474 commit 0596ba5

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

go/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
FROM golang:1.14.1 as delve
22

33
RUN curl --location --output delve-1.4.0.tar.gz https://github.com/go-delve/delve/archive/v1.4.0.tar.gz \
4-
&& tar xzf delve-1.4.0.tar.gz
4+
&& tar xzf delve-1.4.0.tar.gz \
5+
&& mv delve-1.4.0 delve-source
56

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

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

1718
# Now populate the duct-tape image with the language runtime debugging support files
1819
# The debian image is about 95MB bigger

go/delve-only-same-user.patch

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
diff --git delve-1.4.0/cmd/dlv/cmds/commands.go delve-1.4.0/cmd/dlv/cmds/commands.go
2-
index 0a17860..7e46206 100644
3-
--- delve-1.4.0/cmd/dlv/cmds/commands.go
4-
+++ delve-1.4.0/cmd/dlv/cmds/commands.go
1+
Patch delve to default --only-same-user to false [1].
2+
Required as connections proxied via `kubectl port-forward` come from
3+
the outside of the pod, and so connecting to the dlv port is refused.
4+
5+
[1] https://github.com/go-delve/delve/pull/1764
6+
7+
--- cmd/dlv/cmds/commands.go
8+
+++ cmd/dlv/cmds/commands.go
59
@@ -114,7 +114,7 @@ func New(docCall bool) *cobra.Command {
610
RootCommand.PersistentFlags().StringVar(&BuildFlags, "build-flags", buildFlagsDefault, "Build flags, to be passed to the compiler.")
711
RootCommand.PersistentFlags().StringVar(&WorkingDir, "wd", ".", "Working directory for running the program.")

0 commit comments

Comments
 (0)