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

Question : How to attach a debugger during image building #129

Closed
stefferro opened this issue Jan 5, 2022 · 2 comments
Closed

Question : How to attach a debugger during image building #129

stefferro opened this issue Jan 5, 2022 · 2 comments
Labels
type:question A user question

Comments

@stefferro
Copy link

Hi there,

This is more a question than an issue, but it might result as an enhancement.

I am working on a Spring Boot POC application that I build in native using Spring Boot buildpack. During the native image build process, there is a NullPointerException in a GraalVM class I would like to investigate.

The native-image argument --debug-attach allows me to attach a debugger during the image building but I am unable to connect, I presume, because the port number is not exposed. I may be underestimating the difficulty, but would it be possible to expose the port mentioned in the aforementioned argument ?

Thank you in advance of your advice

@dmikusa dmikusa added the type:question A user question label Jan 5, 2022
@dmikusa
Copy link
Contributor

dmikusa commented Jan 5, 2022

The challenge is going to be getting network access, as you said. I don't thing that Spring Boot's build commands or pack allow this. They both run your build inside a container, but there are no options I'm aware of to expose ports on those build containers.

You might be able to use a process similar to this one to run the buildpack in a VM or container that you create, thereby allowing you to expose ports. It's a bit of work though, so you'll have to determine if that's worth it for you.

I don't know if this would be feasible, but you should be able to docker ps and docker exec into the build container. Most of the time they are short-lived so this would be difficult, but with native image, the builds take a while so if you're quick you might be able to exec in and inspect over the CLI.

With Spring Boot, you can also build using native image tools locally. Again, it's a little setup work but you could use those instructions to build locally or in a VM/container and attach directly to the port.

Hope that helps!

@stefferro
Copy link
Author

Thanks @dmikusa-pivotal for your feedback.

I will have a look at your recommendations.

@dmikusa dmikusa closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question A user question
Projects
None yet
Development

No branches or pull requests

2 participants