Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Add Dockerfile for debugging #370

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
46 changes: 46 additions & 0 deletions debug/debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

# Install delve (go debugger)
RUN go install github.com/go-delve/delve/cmd/dlv@latest

RUN go build -gcflags="all=-N -l" -o konveyor-analyzer ./cmd/analyzer/main.go
RUN go build -gcflags="all=-N -l" -o konveyor-analyzer-dep ./cmd/dep/main.go
RUN cd external-providers/generic-external-provider && go mod edit -replace=github.com/konveyor/analyzer-lsp=../../ && go build -gcflags="all=-N -l" -o generic-external-provider main.go
RUN cd external-providers/golang-dependency-provider && go mod edit -replace=github.com/konveyor/analyzer-lsp=../../ && go build -gcflags="all=-N -l" -o golang-dependency-provider main.go

FROM jaegertracing/all-in-one:latest AS jaeger-builder

# The unofficial base image w/ jdtls and gopls installed
FROM quay.io/konveyor/jdtls-server-base

COPY --from=jaeger-builder /go/bin/all-in-one-linux /usr/bin/

COPY --from=builder /analyzer-lsp/konveyor-analyzer /usr/bin/konveyor-analyzer
COPY --from=builder /analyzer-lsp/konveyor-analyzer-dep /usr/bin/konveyor-analyzer-dep
COPY --from=builder /analyzer-lsp/external-providers/generic-external-provider/generic-external-provider /usr/bin/generic-external-provider
COPY --from=builder /analyzer-lsp/external-providers/golang-dependency-provider/golang-dependency-provider /usr/bin/golang-dependency-provider

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

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

WORKDIR /analyzer-lsp

EXPOSE 16686 40000

ENTRYPOINT ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec"]
CMD ["/usr/bin/konveyor-analyzer"]
Loading