-
Notifications
You must be signed in to change notification settings - Fork 59
Manual set up for remote debugging in Rider
Example of enabling remote debugging in Rider for Cloud Code Sample project.
The team is still investigating an integrated solution for remote debugging in Rider. This is a guide to setting it up manually as a workaround in the meantime.
This configuration is not suitable for production, you may wish to create a separate Dockerfile with ssh configuration for debugging purposes, and use a separate skaffold profile for port forwarding. This guide shows the simplest version of the set up.
Rider supports remote debugging via ssh, so we need to ensure ssh server is installed in our remote container and expose the connection via port forwarding.
Update your Dockerfile to
- Install
openssh-server
. - Update your ssh config to allow for password authentication, and if necessary, enable log in as root.
- Set the password for the user if it is not already set.
- Enable ssh
- Modify entrypoint to start SSH before starting the application
# Dockerfile
RUN apt-get update \
- && apt-get install -y unzip procps curl bash \
+ && apt-get install -y unzip procps curl bash openssh-server \
&& rm -rf /var/lib/apt/lists/*
+RUN echo 'root:<SOME_PASSWORD>' | chpasswd
+RUN echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
+RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
+RUN update-rc.d ssh enable
-ENTRYPOINT ["dotnet", "helloworld.dll"]
+ENTRYPOINT ["bash", "-c", "/etc/init.d/ssh start && dotnet helloworld.dll"]
Forward the port your ssh server is running on from the deployment you want to debug. I used the default port, 22, and chose to forward it to 5022.
// skaffold.yaml
portForward:
- resourceType: Deployment
resourceName: dotnet-hello-world
port: 22
localPort: 5022
In Settings | Build, Execution, Deploymnet | Debugger | Remote Debug
, create a new connection config using localhost, the local port you chose from the previous step, and the ssh credentials for the container you want to debug.
Add a Cloud Code: Kubernetes
run configuration to the project if it does not already exist (or from the tools menu, click Cloud Code | Kubernetes | Add Kubernetes Support
) and start the run configuration in debug mode.
Once the application is running and skaffold has forwarded the ssh port, attach to the remote process by going to the run menu and clicking Attach to remote process
.
You will be prompted to install the debug tools on the remote container. If you don't see this prompt the first time you run Attach to remote process
, just try running it again.
Once the debug tools have installed, you'll be prompted to choose which application to connect to.
That's it! You should now be able to hit breakpoints in the application.