Skip to content

Commit 56f1811

Browse files
committed
Add go remote debugging support in TILT
1 parent feaf68a commit 56f1811

4 files changed

Lines changed: 44 additions & 2 deletions

File tree

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Docker Go Debug",
6+
"type": "go",
7+
"request": "attach",
8+
"mode": "remote",
9+
"remotePath": "/root",
10+
"debugAdapter": "dlv-dap",
11+
"hideSystemGoroutines": true,
12+
"showGlobalVariables": true,
13+
"substitutePath": [
14+
{
15+
"from": "${workspaceFolder}/flow",
16+
"to": "/root/flow"
17+
}
18+
],
19+
"port": 40000,
20+
"host": "127.0.0.1"
21+
}
22+
]
23+
}

Tiltfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ docker_build('flow-api', '.',
1616

1717
docker_build('flow-worker', '.',
1818
dockerfile='stacks/flow.Dockerfile',
19-
target='flow-worker',
19+
target='flow-worker-debug',
2020
only=['flow/', 'stacks/flow.Dockerfile'],
21+
build_args={'DEBUG_BUILD':'1'},
2122
ignore=flow_ignore,
2223
)
2324

docker-compose-dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ services:
161161
context: .
162162
dockerfile: stacks/flow.Dockerfile
163163
target: flow-worker
164+
ports:
165+
- 40000:40000
164166
environment:
165167
<<: [*catalog-config, *flow-worker-env, *minio-config]
166168
extra_hosts:

stacks/flow.Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# syntax=docker/dockerfile:1.23@sha256:2780b5c3bab67f1f76c781860de469442999ed1a0d7992a5efdf2cffc0e3d769
22

33
FROM golang:1.26-alpine@sha256:f85330846cde1e57ca9ec309382da3b8e6ae3ab943d2739500e08c86393a21b1 AS builder
4+
# Allow build flags to be passed in at build time, for example debug flags
5+
ARG DEBUG_BUILD
6+
ENV DEBUG_BUILD=${DEBUG_BUILD}
7+
48
RUN apk add --no-cache gcc geos-dev musl-dev
59
WORKDIR /root/flow
610

@@ -21,7 +25,8 @@ ENV CGO_ENABLED=1
2125
# Generate the typed handler wrapper
2226
RUN go generate
2327
ENV GOCACHE=/root/.cache/go-build
24-
RUN --mount=type=cache,target="/root/.cache/go-build" go build -o /root/peer-flow
28+
RUN --mount=type=cache,target="/root/.cache/go-build" go build ${DEBUG_BUILD:+-gcflags} ${DEBUG_BUILD:+"all=-N -l"} -o /root/peer-flow
29+
RUN --mount=type=cache,target="/root/.cache/go-build" go install github.com/go-delve/delve/cmd/dlv@latest
2530

2631
FROM alpine:3.23@sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11 AS flow-base
2732
ENV TZ=UTC
@@ -58,6 +63,17 @@ ENV PEERDB_VERSION_SHA_SHORT=${PEERDB_VERSION_SHA_SHORT}
5863
ENTRYPOINT ["./peer-flow", "snapshot-worker"]
5964

6065

66+
FROM flow-base AS flow-worker-debug
67+
ENV OTEL_METRIC_EXPORT_INTERVAL=10000
68+
ENV OTEL_EXPORTER_OTLP_COMPRESSION=gzip
69+
ARG PEERDB_VERSION_SHA_SHORT
70+
ENV PEERDB_VERSION_SHA_SHORT=${PEERDB_VERSION_SHA_SHORT}
71+
USER root
72+
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
73+
USER peerdb
74+
EXPOSE 40000
75+
ENTRYPOINT ["dlv", "--headless", "--continue", "--accept-multiclient", "--listen=:40000", "--api-version=2", "exec", "./peer-flow", "--", "worker"]
76+
6177
FROM flow-base AS flow-maintenance
6278

6379
ARG PEERDB_VERSION_SHA_SHORT

0 commit comments

Comments
 (0)