Skip to content

Commit

Permalink
Make Go debugger configuration consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewL246 committed Aug 7, 2024
1 parent 70cf197 commit 6f2634d
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 105 deletions.
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,33 @@
"debugAdapter": "legacy",
"port": 2348,
"host": "127.0.0.1"
},
{
"type": "go",
"request": "attach",
"name": "Debug splatoon",
"mode": "remote",
"debugAdapter": "legacy",
"port": 2349,
"host": "127.0.0.1"
},
{
"type": "go",
"request": "attach",
"name": "Debug minecraft-wiiu",
"mode": "remote",
"debugAdapter": "legacy",
"port": 2350,
"host": "127.0.0.1"
},
{
"type": "go",
"request": "attach",
"name": "Debug pikmin-3",
"mode": "remote",
"debugAdapter": "legacy",
"port": 2351,
"host": "127.0.0.1"
}
]
}
9 changes: 9 additions & 0 deletions .vscode/pretendo-docker.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@
{
"path": "../repos/miiverse-api"
},
{
"path": "../repos/minecraft-wiiu"
},
{
"path": "../repos/mitmproxy-pretendo"
},
{
"path": "../repos/pikmin-3"
},
{
"path": "../repos/splatoon"
},
{
"path": "../repos/SSSL"
},
Expand Down
12 changes: 6 additions & 6 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ services:
restart: always
ports:
# Go delve debugger
- 127.0.0.1:2346:2346
- 127.0.0.1:2346:2345
# Authentication server
- 6002:6002/udp
networks:
Expand All @@ -394,7 +394,7 @@ services:
restart: always
ports:
# Go delve debugger
- 127.0.0.1:2347:2347
- 127.0.0.1:2347:2345
# Secure server
- 6003:6003/udp
networks:
Expand All @@ -413,7 +413,7 @@ services:
restart: always
ports:
# Go delve debugger
- 127.0.0.1:2348:2348
- 127.0.0.1:2348:2345
# Authentication server
- 6004:6004/udp
# Secure server
Expand All @@ -433,7 +433,7 @@ services:
restart: unless-stopped
ports:
# Go delve debugger
- 127.0.0.1:2351:2350
- 127.0.0.1:2349:2345
# Authentication server
- 6006:6006/udp
# Secure server
Expand All @@ -452,7 +452,7 @@ services:
restart: unless-stopped
ports:
# Go delve debugger
- 127.0.0.1:2352:2350
- 127.0.0.1:2350:2345
# Authentication server
- 6008:6008/udp
# Secure server
Expand All @@ -472,7 +472,7 @@ services:
restart: unless-stopped
ports:
# Go delve debugger
- 127.0.0.1:2353:2353
- 127.0.0.1:2351:2349
# Authentication server
- 6010:6010/udp
# Secure server
Expand Down
8 changes: 4 additions & 4 deletions patches/friends/dockerfile-enable-debugging.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git i/Dockerfile w/Dockerfile
index 8d3c4c1..055911b 100644
index 20b2b7a..60e3ee3 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir build_string=pretendo.friends.docker
@@ -10,6 +10,8 @@ ARG build_string=pretendo.friends.docker

WORKDIR ${app_dir}

Expand All @@ -11,7 +11,7 @@ index 8d3c4c1..055911b 100644
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
@@ -16,7 +18,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \
@@ -17,7 +19,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . .
RUN --mount=type=cache,target=/go/pkg/mod/ \
Expand All @@ -20,7 +20,7 @@ index 8d3c4c1..055911b 100644


# * Running the final application
@@ -31,6 +33,7 @@ RUN chown go:go ${app_dir}/log
@@ -31,6 +33,7 @@ RUN mkdir -p ${app_dir}/log && chown go:go ${app_dir}/log

USER go

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/Dockerfile b/Dockerfile
index 94effb5..902eb1e 100644
--- a/Dockerfile
+++ b/Dockerfile
diff --git i/Dockerfile w/Dockerfile
index 94effb5..509b71c 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir

WORKDIR ${app_dir}
Expand All @@ -16,7 +16,7 @@ index 94effb5..902eb1e 100644
ARG BUILD_STRING=pretendo.minecraftwiiu.docker
RUN --mount=type=cache,target=/go/pkg/mod/ \
- CGO_ENABLED=0 go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server
+ CGO_ENABLED=0 go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server -gcflags "all=-N -l"
+ CGO_ENABLED=0 go build -gcflags "all=-N -l" -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server


# * Running the final application
Expand All @@ -28,5 +28,4 @@ index 94effb5..902eb1e 100644
COPY --from=build ${app_dir}/build/server ${app_dir}/server

-CMD [ "./server" ]
+CMD ["./dlv", "exec", "./server", "--listen=:2348", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
\ No newline at end of file
+CMD ["./dlv", "exec", "./server", "--listen=:2345", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
35 changes: 0 additions & 35 deletions patches/pikmin-3/adjust-docker.patch

This file was deleted.

28 changes: 28 additions & 0 deletions patches/pikmin-3/dockerfile-enable-debugging.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git i/Dockerfile w/Dockerfile
index 3e08c61..ca3fcf9 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir

WORKDIR ${app_dir}

+RUN go install github.com/go-delve/delve/cmd/dlv@latest
+
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
@@ -17,7 +19,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \
COPY . .
ARG BUILD_STRING=pretendo.pikmin3.docker
RUN --mount=type=cache,target=/go/pkg/mod/ \
- CGO_ENABLED=0 go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server
+ CGO_ENABLED=0 go build -gcflags "all=-N -l" -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server


# * Running the final application
@@ -33,4 +35,4 @@ USER go

COPY --from=build ${app_dir}/build/server ${app_dir}/server

-CMD [ "./server" ]
+CMD ["./dlv", "exec", "./server", "--listen=:2345", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
28 changes: 28 additions & 0 deletions patches/splatoon/dockerfile-enable-debugging.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git i/Dockerfile w/Dockerfile
index fb8db39..93b708b 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir

WORKDIR ${app_dir}

+RUN go install github.com/go-delve/delve/cmd/dlv@latest
+
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
@@ -16,7 +18,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . .
RUN --mount=type=cache,target=/go/pkg/mod/ \
- CGO_ENABLED=0 go build -v -o ${app_dir}/build/server
+ CGO_ENABLED=0 go build -gcflags "all=-N -l" -v -o ${app_dir}/build/server


# * Running the final application
@@ -32,4 +34,4 @@ USER go

COPY --from=build ${app_dir}/build/server ${app_dir}/server

-CMD [ "./server" ]
+CMD ["./dlv", "exec", "./server", "--listen=:2345", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
23 changes: 0 additions & 23 deletions patches/splatoon/dockerize.patch

This file was deleted.

17 changes: 7 additions & 10 deletions patches/super-mario-maker/dockerfile-enable-debugging.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/Dockerfile b/Dockerfile
index 2a929a4..b3366ea 100644
--- a/Dockerfile
+++ b/Dockerfile
diff --git i/Dockerfile w/Dockerfile
index 2a929a4..4aa6bbe 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir

WORKDIR ${app_dir}
Expand All @@ -16,16 +16,13 @@ index 2a929a4..b3366ea 100644
ARG BUILD_STRING=pretendo.supermariomaker.docker
RUN --mount=type=cache,target=/go/pkg/mod/ \
- CGO_ENABLED=0 go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server
+ CGO_ENABLED=0 go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server -gcflags "all=-N -l"
+ CGO_ENABLED=0 go build -gcflags "all=-N -l" -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o ${app_dir}/build/server


# * Running the final application
@@ -31,6 +33,7 @@ RUN mkdir -p ${app_dir}/log && chown go:go ${app_dir}/log
@@ -33,4 +35,4 @@ USER go

USER go

+COPY --from=build /go/bin/dlv ${app_dir}/dlv
COPY --from=build ${app_dir}/build/server ${app_dir}/server

-CMD [ "./server" ]
+CMD ["./dlv", "exec", "./server", "--listen=:2348", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
+CMD ["./dlv", "exec", "./server", "--listen=:2345", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
20 changes: 10 additions & 10 deletions patches/wiiu-chat-authentication/dockerfile-enable-debugging.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/Dockerfile b/Dockerfile
index fb8db39..7817e6a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir
diff --git i/Dockerfile w/Dockerfile
index 20b2b7a..60e3ee3 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -10,6 +10,8 @@ ARG build_string=pretendo.friends.docker

WORKDIR ${app_dir}

Expand All @@ -11,21 +11,21 @@ index fb8db39..7817e6a 100644
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
@@ -16,7 +18,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \
@@ -17,7 +19,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . .
RUN --mount=type=cache,target=/go/pkg/mod/ \
- CGO_ENABLED=0 go build -v -o ${app_dir}/build/server
+ CGO_ENABLED=0 go build -v -o ${app_dir}/build/server -gcflags "all=-N -l"
- CGO_ENABLED=0 go build -v -o ${app_dir}/build/server -ldflags "-X 'main.serverBuildString=${build_string}'"
+ CGO_ENABLED=0 go build -v -o ${app_dir}/build/server -gcflags "all=-N -l" -ldflags "-X 'main.serverBuildString=${build_string}'"


# * Running the final application
@@ -30,6 +32,7 @@ RUN mkdir -p ${app_dir}/log && chown go:go ${app_dir}/log
@@ -31,6 +33,7 @@ RUN mkdir -p ${app_dir}/log && chown go:go ${app_dir}/log

USER go

+COPY --from=build /go/bin/dlv ${app_dir}/dlv
COPY --from=build ${app_dir}/build/server ${app_dir}/server

-CMD [ "./server" ]
+CMD ["./dlv", "exec", "./server", "--listen=:2346", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
+CMD ["./dlv", "exec", "./server", "--listen=:2345", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
20 changes: 10 additions & 10 deletions patches/wiiu-chat-secure/dockerfile-enable-debugging.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/Dockerfile b/Dockerfile
index fb8db39..08da995 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,6 +9,8 @@ ARG app_dir
diff --git i/Dockerfile w/Dockerfile
index 20b2b7a..60e3ee3 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -10,6 +10,8 @@ ARG build_string=pretendo.friends.docker

WORKDIR ${app_dir}

Expand All @@ -11,21 +11,21 @@ index fb8db39..08da995 100644
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
@@ -16,7 +18,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \
@@ -17,7 +19,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

COPY . .
RUN --mount=type=cache,target=/go/pkg/mod/ \
- CGO_ENABLED=0 go build -v -o ${app_dir}/build/server
+ CGO_ENABLED=0 go build -v -o ${app_dir}/build/server -gcflags "all=-N -l"
- CGO_ENABLED=0 go build -v -o ${app_dir}/build/server -ldflags "-X 'main.serverBuildString=${build_string}'"
+ CGO_ENABLED=0 go build -v -o ${app_dir}/build/server -gcflags "all=-N -l" -ldflags "-X 'main.serverBuildString=${build_string}'"


# * Running the final application
@@ -30,6 +32,7 @@ RUN mkdir -p ${app_dir}/log && chown go:go ${app_dir}/log
@@ -31,6 +33,7 @@ RUN mkdir -p ${app_dir}/log && chown go:go ${app_dir}/log

USER go

+COPY --from=build /go/bin/dlv ${app_dir}/dlv
COPY --from=build ${app_dir}/build/server ${app_dir}/server

-CMD [ "./server" ]
+CMD ["./dlv", "exec", "./server", "--listen=:2347", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]
+CMD ["./dlv", "exec", "./server", "--listen=:2345", "--headless", "--api-version=2", "--log", "--accept-multiclient", "--continue"]

0 comments on commit 6f2634d

Please sign in to comment.