2019-04-17: How to run Visual Studio Code in a browser

What is this?

The guys at https://coder.com/ have created something wonderful: https://github.com/codercom/code-server.

This is a headless Visual Studio Code server that is then accessible in a browser.

Notice the firefox:)

This opens up a lot of new debugging possibilities such as running Visual Studio Code inside a container and debug directly from within! Push "F5" to debug directly an application inside a Container such as a Python application. This is powerful stuff.

The original Dockerfile is here: https://github.com/codercom/code-server/blob/master/Dockerfile, but has some limitations that you will experience when debugging your own stuff.

I added the power to use the terminal as you would in any other normal usage of the Visual Studio Code locally. Beware of the security implications.


How to run

Docker hub: https://cloud.docker.com/u/geircode/repository/docker/geircode/headless_vscode

docker logs -f headless_vscode-1



A new way to debug remotely

It's possible to add this headless server to any container and then debug your application directly while it's running in the cloud. Sometimes it's nice to have the chance to debug the application while the container is running in the clould, because of some third party integration endpoints are only accessible from the cloud environment. 

Let's debug a .net core application. In order to start and stop the debugging without restarting the container, the .net core process needs to start from Visual Studio Code. The container will then host two 'services': the .net core application and the headless service, and expose each on different ports.

For the .net core application, I will use this useful repository that is also showing how to use GraphQL => https://github.com/CodeMazeBlog/graphql-series/tree/getting-started-with-graphql

But first, I need to remake/refactor this application to be running in a Container, using Kestrel and a Postgres database.