Skip to content

Commit

Permalink
Add README, move to 'debug'
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
  • Loading branch information
jmle committed Nov 21, 2023
1 parent 3b3c5ac commit 4728289
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
12 changes: 12 additions & 0 deletions debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Debugging within the container
==
Given the containerized nature of the analyzer, and its dependency on external components, many times it will be convenient to debug its code
running inside a container. This can be achieved by executing the main command with the [Go Delve debugger](https://github.com/go-delve/delve).

`debug.Dockerfile` makes it possible to do this, and also to connect from an external IDE, like GoLand or VSCode.

### Debugging from Goland
You can follow [these instructions](https://blog.jetbrains.com/go/2020/05/06/debugging-a-go-application-inside-a-docker-container/) to debug the analyzer from the GoLand IDE.

### Debugging from VSCode
Follow [this blog post](https://dev.to/bruc3mackenzi3/debugging-go-inside-docker-using-vscode-4f67) to debug from VSCode. The Dockerfile creation steps can be skipped.
26 changes: 13 additions & 13 deletions debug.Dockerfile → debug/debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM golang:1.19 as builder
WORKDIR /analyzer-lsp

COPY cmd /analyzer-lsp/cmd
COPY engine /analyzer-lsp/engine
COPY output /analyzer-lsp/output
COPY jsonrpc2 /analyzer-lsp/jsonrpc2
COPY lsp /analyzer-lsp/lsp
COPY parser /analyzer-lsp/parser
COPY provider /analyzer-lsp/provider
COPY tracing /analyzer-lsp/tracing
COPY external-providers /analyzer-lsp/external-providers
COPY go.mod /analyzer-lsp/go.mod
COPY go.sum /analyzer-lsp/go.sum
COPY Makefile /analyzer-lsp/Makefile
COPY ../cmd /analyzer-lsp/cmd
COPY ../engine /analyzer-lsp/engine
COPY ../output /analyzer-lsp/output
COPY ../jsonrpc2 /analyzer-lsp/jsonrpc2
COPY ../lsp /analyzer-lsp/lsp
COPY ../parser /analyzer-lsp/parser
COPY ../provider /analyzer-lsp/provider
COPY ../tracing /analyzer-lsp/tracing
COPY ../external-providers /analyzer-lsp/external-providers
COPY ../go.mod /analyzer-lsp/go.mod
COPY ../go.sum /analyzer-lsp/go.sum
COPY ../Makefile /analyzer-lsp/Makefile

# Install delve (go debugger)
RUN go install github.com/go-delve/delve/cmd/dlv@latest
Expand All @@ -36,7 +36,7 @@ COPY --from=builder /analyzer-lsp/external-providers/golang-dependency-provider/

COPY --from=builder /go/bin/dlv /

COPY provider_container_settings.json /analyzer-lsp/provider_settings.json
COPY ../provider_container_settings.json /analyzer-lsp/provider_settings.json

WORKDIR /analyzer-lsp

Expand Down

0 comments on commit 4728289

Please sign in to comment.