Self Hosting a Cloud IDE

This is the second post about self hosting. The previous post was about setting up a Sentry server for tracking application errors. I think that for non-critical applications or for a personal playground, having a home lab is the perfect place to test things out. My configuration is pretty simple, I have a few refurbished rack servers, each running as a Proxmox Hypervisor. The thing that I love about Proxmox is that it gives the flexibility of KVM or LXC virtualization. KVM is the more traditional type of virtual machine that you may find from someone like Digital Ocean. However a LXC is more like a Docker Container. LXC is very lightweight and has a low overhead and shares the kernel with its host.

In this post, we’re going to look at the Cloud9 IDE, a company which was acquired by Amazon. While they do offer hosted services, you also have the option to self host the application in your own environment. Setting up the environment isn’t too difficult, but this article should help you unless you’re familiar with Linux and getting services to start any time the server is rebooted.

So we’ll get started with updating our environment and installing a few dependencies. In this tutorial, we’ll be using an Ubuntu 16.04.2 LTS LXC (which doesn’t come with curl by default). However, the tutorial should work with many Debian based systems. Our end goal is to be able to have a functioning Cloud9 development environment that we can access from our remote/mobile device. What is out of scope for this article is securing the app behind HTTPS and the necessary networking for opening up your firewall for outside access. Regardless, googling around should yield some results. Perhaps in a later article, I’ll show you how to create a reverse proxy and configure a firewall for your home lab.

We can then download and install node.

I then like to create a user which in this example, I am calling c9user. We will create the user. Be sure to remember the password that you set for the user. Once the user is created, we will allow the user to use sudo.

Close your shell session and ssh back in as your c9user user.

We can then get down to the better bits. We will download the Cloud9 Core package and run the initial setup. We then create a folder called projects in our home directory where our projects will reside.

Let’s go ahead and test the install! Once you have finished running the scripts, we will need to be sure that everything is working properly. We can change our directory to the c9sdk in our home folder. From there, we can run the service. We’ll set a basic auth so that the environment is protected but not secure. You still need HTTPS. We will also start the service with a workspace of our created projects folder.

-p 8080 option allows the service to listen on port 8080

-a user:pass will enable basic authentication on the service. This will protect the service from unauthorized access. However, you still need to enable SSL

--listen X.X.X.X will allow the service to listen on the IP Address of the machine instead of the localhost. This is needed if you’re going to allow outside access (from within your own network or the world).

-w /home/c9user/projects will set the workspace of Cloud9 to your projects directory.

Now that everything is working, we can stop the service with CTRL + C. We then want the service to start whenever the computer is rebooted and also be headless so we don’t have to keep a terminal session open indefinitely.

We will edit the sudo vi /lib/systemd/system/c9.service file. Use nano if that suites you better than vi.

We will add the below to our c9.service file. This is basically the service that will run our headless node server. Be sure to change the IP Address, Username and Password (and any other settings you may have changed to the service command) under the [Service] -> ExecStart section.

We can then enable the service.

You should now be able to access your application under http://X.X.X.X:8080.

Now, you can install Ruby and all of the dependencies that you need for developing your application! This setup is the same as having a Ubuntu development environment with the exception of a cloud based editor. You get direct access to the terminal from the IDE and can install Ruby and everything that you may need from right there.