Improve debug configuration.
All checks were successful
Linting and tests / Linting (push) Successful in 5s

This commit is contained in:
Stanislav Nikitin 2025-09-15 17:22:59 +05:00
parent b787a2b22a
commit cc5d010204
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
5 changed files with 42 additions and 8 deletions

5
.vscode/launch.json vendored
View File

@ -16,10 +16,11 @@
"substitutePath": [
{
"from": "${workspaceFolder}",
"to": "bunker"
"to": "/bunkerd/"
}
],
"preLaunchTask": "Run bunkerd debug build"
"preLaunchTask": "Run bunkerd debug build",
"postDebugTask": "Stop bunkerd debug build"
}
]
}

17
.vscode/tasks.json vendored
View File

@ -4,9 +4,22 @@
{
"label": "Run bunkerd debug build",
"type": "shell",
"command": "task server:localdev:bunkerd:stop; task server:localdev:bunkerd:build-debug && task server:localdev:bunkerd:restart-debug",
"command": "task server:localdev:bunkerd:down; task server:localdev:bunkerd:up-debug",
"group": {
"kind": "test",
"kind": "build",
"isDefault": true
},
"presentation": {
// Do not open terminal every time debug is launched.
"reveal": "silent"
}
},
{
"label": "Stop bunkerd debug build",
"type": "shell",
"command": "task server:localdev:bunkerd:down-debug",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {

View File

@ -2,15 +2,17 @@ FROM code.pztrn.name/containers/go-toolbox:v8 AS build
WORKDIR /bunkerd
COPY . /bunkerd
RUN --mount=type=cache,target="/home/container/go" task server:cmd:bunkerd:build --force
RUN --mount=type=cache,target="/home/container/go" GOFLAGS="" task server:cmd:bunkerd:build-debug --force
FROM debian:13-slim
RUN apt-get update && \
apt-get install -y ca-certificates iputils-ping coreutils && \
apt-get install -y ca-certificates iputils-ping coreutils curl net-tools && \
rm -rf /var/lib/apt/* /var/cache/apt/*
COPY --from=build /bunkerd/_build/bunkerd /bunkerd
COPY --from=build /usr/local/bin/dlv /dlv
HEALTHCHECK --interval=1s --timeout=10s --start-period=1s --retries=3 CMD netstat -an | grep 4000 > /dev/null; if [ 0 != $? ]; then exit 1; fi;
ENTRYPOINT ["/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "exec", "/bunkerd"]

View File

@ -20,6 +20,24 @@ tasks:
- ./_build/bunkerd{{exeExt}}
method: timestamp
build-debug:
desc: "Builds bunkerd binary."
cmds:
- task: :::ensure-builddir
- task: cleanup
- go build -ldflags="{{ .BASIC_LDFLAGS }}" --gcflags "all=-N -l" -o _build/bunkerd{{exeExt}} ./server/cmd/bunkerd/main.go
sources:
- ./Taskfile.yml
- ./go.mod
- ./commons/*
- ./server/**/*.go
- ./server/Taskfile.yml
- ./server/**/Taskfile.yml
- ./server/entrypoint.sh
generates:
- ./_build/bunkerd{{exeExt}}
method: timestamp
cleanup:
desc: "Deletes bunkerd binary from local build cache."
cmds:

View File

@ -87,5 +87,5 @@ tasks:
dir: "./server/localdevzone/bunkerd"
cmds:
- task: :common:network-up
- task: build
- docker compose -p bunkerd-debug -f docker-compose.debug.yaml up -d
- task: build-debug
- docker compose -p bunkerd-debug -f docker-compose.debug.yaml up -d --wait