How to Deploy Visual Studio Code on Railway
A brief guide to deploying Visual Studio Code on Railway using the open source code-server.
Using VS Code for remote development offers several benefits in productivity and collaboration, scalability, security and consistency. In this post, we'll walk through the deployment of a remote VS Code environment on Railway.
What is Visual Studio Code?
Visual Studio Code (VS Code) is an extremely popular code editor developed by Microsoft. It is designed to be lightweight and highly customisable, with a huge variety of extensions and plugins available. It supports debugging, syntax highlighting, intelligent code completion, code refactoring, and a whole host of other features. VS Code can be used to develop on a remote server, aiding collaboration, and ensuring a consistent environment across different machines.
What is Code Server?
Code-server, from Coder, is an open-source project that allows you to deploy VS Code on a remote/cloud machine, and access it via your web browser. You can deploy code-server using the install script, manually, using the coder platform, or using one-click templates to cloud providers like AWS, GCP and DigitalOcean. In this post, we'll explore the option to deploy on Railway.
What is Railway?
Railway is a modern app hosting platform that makes it easy to deploy production-ready apps quickly. Railway offers persistent database services for PostgreSQL, MySQL, MongoDB, and Redis, as well as application services with a GitHub repository as the deployment source. For the latter, Railway can automatically determine the application runtime and deploy the service. Railway offers several one-click starters for popular applications, including VS Code. Since we are just testing the waters, Railway's free tier should be sufficient to host the service.
Deploy VS Code using One-Click Starter on Railway
Sign up for an account with Railway using GitHub, and click
Authorize Railway App when redirected. Review and agree to Railway's Terms of Service and Fair Use Policy if prompted. Launch the VS Code one-click starter template (or click the button below) to deploy VS Code instantly on Railway.
You'll be given an opportunity to change the default repository name and set it private, if you'd like. You'll need to specify a
PASSWORD to log into the server once deployed, and the
GIT_REPO to auto-clone and open upon launch. Provide the details and click
Deploy; the deployment will kick off immediately.
Once the deployment completes, a VS Code environment will be available at a default
xxx.up.railway.app domain - launch this URL to access the app. Provide the password that you configured earlier, and click
Submit. If you are interested in setting up a custom domain, I covered it at length in a previous post - see the final section here.
Once you log in, a clone of the GitHub repository that you specified earlier will be available for remote development in your web browser!
Configure Missing Packages in VS Code
Now, if you try to actually debug or run the code, you'll get an error about missing runtime binaries. Open the linked source repo
code-server in GitHub and edit the
Dockerfile. Add custom packages like
NodeJS and push to the main branch. Railway will automatically trigger a new deployment. Once the deployment completes, you can use these installed packages in your VS Code environment.
# Install NodeJS RUN sudo curl -fsSL https://deb.nodesource.com/setup_15.x | sudo bash - RUN sudo apt-get install -y nodejs
In conclusion, deploying a VS Code environment on Railway is a straightforward process, made even easier by the one-click template. Go forth and deploy!