c9 + pair-programming. Lazy Jar — Part #4
This is part four of a series of article on Lazy Jar. A slack app for scheduling remote stand-ups and tracking participation in Node.js. Fork the repo to start experimenting. If you’re new to this project? Start with the introduction.
When we started writing the OAuth section of the app — getting the user command from Slack, we decided to try out pair programming to get it done. To do this we needed a shared editor we could work on together remotely. Unfortunately, at the time VSCode had not released their live share feature yet — VSCode fans here — and we did not want to struggle with screen sharing on google hangouts so we decided to set up c9 on google cloud. This article will be a step by step tutorial on how we did this.
Step 1: Creating a Project
To get started go to the Google Cloud Console. It should look like something like this.
If you have not used Google Cloud Platform before, you can activate your free trial.
After setting up your free trial, it’s time to create a new project. Click the select a project
button on the top left of the page.
A pop up will appear prompting you to enter your project details.
Once your new project has been created, go to the project main page and select compute engine
on the left hand menu. Select VM instances
.
Click create
to get started with your VM configurations.
Step 2: Configuring the VM Instance
Here we configured the VM in the following ways (feel free to make changes as you see fit)
Zone
We chose Central America as our zone for the VM instance, but you can always change it to a data centre closer to you.
Machine Type
We chose the micro
option here. We decided to go with the cheaper option as that was sufficient for our needs.
Boot Disk
We chose Ubuntu 16.04 LTS here because our team feels comfortable with this OS and there is good support on the internet for it.
Identity and API access
For the service account
we chose the compute engine default service account.
In the default case, access to any extra google cloud service is disabled — we won’t be needing any of extra services to set up a c9 instance.
For the access scopes
option we set the default, since we won’t be needing any special access.
Firewall
The firewall should be configured to allow HTTP traffic. We do this because we need to expose a port to the public internet so that a user can access the c9 instance running on the VM via an http request.
Step 3: Setting up the cloud9 IDE
Now we have created an instance, we can SSH into it and set up our c9 IDE. Go to your Compute Engine VM Instances. In the drop down SSH
menu of your VM you just created, select theView gcloud command
option.
Next, click RUN IN CLOUD SHELL
and a terminal will open up. Press enter to run the command already pasted into the terminal. Press Y
when prompted to continue. It will ask you to enter a passphrase — here you can just press enter.
Now that we have the instance up and running , its time to set up the shared c9 instance. Type the following commands into your terminal:
Here you are cloning the cloud9 repo into your instance.
$ git clone https://github.com/c9/core.git
You need to be in the core directory to run the next few commands.
$ cd core
Run the shell scripts. After this step you might be prompted to install some build essentials like gcc or g++. If you are using Linux you can type sudo apt-get <some build essential, e.g gcc>.
$ Run scripts/install-sdk.sh
We will need to install Node.js to be able to run the app.
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -sudo$ apt-get install -y nodejs
You can now start the c9 application. This command sets up the app to listen to all http requests on port 8051. Setting the IP to 0.0.0.0 allows traffic into the app from the public internet.
$ node server.js — port 8051 — colab — listen 0.0.0.0 — auth dogo:fluffy -w./
Although we have set the c9 app to listen on 8051, the Google Cloud Firewall rules have not been configured to allow incoming traffic through this port. We will do this in the next step.
Step 4: Creating Firewall Rules
On the left hand menu, go to VPC Network Firewall Rules.
Now, click on CREATE FIREWALL RULE
and configure the firewall rules as shown in the screenshot below. We can source ip to be 0.0.0.0/0 and the port to be tcp:8051 . This will allow all traffic to come through.
The last step would be to set the IP address of your VM to static. This is would allow for users to access the c9 instance through the static IP address and port 8051.
Step 5: Configuring a static IP address
To configure a static IP address go to VPC Network External IP addresses in the left hand menu. You will be directed to a page with a list of your vm instances. Under the type
attribute in the drop down menu of the instance you just created, select the static
option.
Step 6: Restart your VM
The last step is to restart your VM and you should be good to go. You can do this by visiting the Compute Engine VM Instances tab, stopping and then starting your instance again (sadly, there is no restart button).
Visiting your C9 Instance
You can now visit your c9 instance from anywhere! Just type in your static IP address and port number in your browser (for example, 15.483.898.891:5081). You will then be prompted to enter the username and password you configured for the app in Step 3.
If you are unsure of what the IP address is of your VM, visit Compute Engine VM instances. The IP address of your instance will be under the External IP attribute.