Juan Carlos García Martínez
Posted on November 20, 2021
Using the free tier of Oracle Cloud, you can create an instance with up to 4 cores and 24 GB of RAM! That's enough for most of my development tasks, and this comes included in Free Tier!.
If you can't switch to ARM architecture, there is option for 2 VMs with 1-core AMD x64 and 1 GB of RAM.
This kind of setup might be useful if you're someone that wants to have a development environment on-the-go, and code in your iPad or a laptop with limited resources, or if you're someone who likes to experiment just like me.
In this guide, we will configure a VM with an Ampere ARM processor to run visual studio code on the web.
First of all, you need to create an account in Oracle Cloud, and remember to select the "Always free" option, that does not asks you for a credit card. This is way more beginner-friendy than other clouds, such as AWS that don't allow a hard-limit on budgets.
Creating an ARM VM
Push "Create an Instance", and a new dialog will appear.
First, you'll need to input a name for the instance.
Next, you can choose the OS image and the VM shape. I choose Ubuntu for this one, and also used Ampere ARM instance type, which you can max out to 4CPUs with 24GB of RAM!
You'll also need to setup the SSH keys you have, or if you prefer you can also create a new one. In this case, I'll use the keys I already have
Click Create, and the instance will start provisioning
Once your VM state is Running, connect to the instance through SSH, using your local terminal:
ssh ubuntu@${PUBLIC_IP}
First and foremost, let's update the packages already installed with the following commands
sudo apt update
sudo apt upgrade -y
Configuring code-server
Then, let's install code-server , which allow us to run vscode as a web server in this instance and connect from our local machines.
Copy the following into the remote session:
curl -fsSL [https://code-server.dev/install.sh](https://code-server.dev/install.sh) | sh
You'll see something similar to this in your shell:
Ubuntu 20.04.3 LTS
Installing v3.12.0 of the arm64 deb package from GitHub.
- Reusing ~/.cache/code-server/code-server_3.12.0_arm64.deb
- sudo dpkg -i ~/.cache/code-server/code-server_3.12.0_arm64.deb
(Reading database ... 112463 files and directories currently installed.)
Preparing to unpack .../code-server_3.12.0_arm64.deb ...
Unpacking code-server (3.12.0) over (3.12.0) ...
Setting up code-server (3.12.0) ...
deb package has been installed.
To have systemd start code-server now and restart on boot:
sudo systemctl enable --now code-server@$USER
Or, if you don't want/need a background service you can run:
code-server
After this, execute in your terminal:
code-server
this will create a default configuration and then start an HTTP server at port 8080. We need to make some changes to the configuration before code is ready to use.
Now, stop the running server with Ctrl+C
, then open the configuration file to enable the self-signed TLS certificate, and also run in the default HTTPS port (443).
Open the ~/.config/code-server/config.yaml
file, and perform two changes in this YAML file:
- Change the
cert
field to true. - Change the
bind-addr
field to0.0.0.0:443
Before starting the server, we need to give proper permissions for the server to run in port 443 and allow the incoming traffic from the internet.
Let's use the setcap command to allow this binary to use the privileged port 443, without running with complete root permissions.
sudo setcap cap_net_bind_service=+ep /usr/lib/code-server/lib/node
Then, we will enable the code-server
service and start it.
sudo systemctl enable --now code-server@$USER
sudo systemctl start code-server@ubuntu
Verify that the service is now running
systemctl status code-server@ubuntu.service
Your console will print out something similar to this
● code-server@ubuntu.service - code-server
Loaded: loaded (/lib/systemd/system/code-server@.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-11-15 23:41:32 UTC; 3min 46s ago
Main PID: 34764 (node)
Tasks: 22 (limit: 21304)
Memory: 40.2M
CGroup: /system.slice/system-code\x2dserver.slice/code-server@ubuntu.service
├─34764 /usr/lib/code-server/lib/node /usr/lib/code-server
└─34783 /usr/lib/code-server/lib/node /usr/lib/code-server
Nov 15 23:41:32 vscode-remote systemd[1]: Starting code-server...
Nov 15 23:41:32 vscode-remote systemd[1]: Started code-server.
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.119Z] info code-server 3.12.0 b37ff28a0a582aee84a8f961755d0cb40a4081db
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.121Z] info Using user-data-dir ~/.local/share/code-server
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.144Z] info Using config file ~/.config/code-server/config.yaml
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.145Z] info HTTP server listening on http://0.0.0.0:443
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.145Z] info - Authentication is enabled
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.145Z] info - Using password from ~/.config/code-server/config.yaml
Nov 15 23:41:33 vscode-remote code-server[34783]: [2021-11-15T23:41:33.145Z] info - Using certificate for HTTPS: ~/.local/share/code-server/localhost.crt
Configure the VNC Ingress rules
Even if the server is running, we're not able to access it from the external IP address, because of the firewall rules are not allowing the incoming connections.
Let's configure the network rules in order to allow connections to the running port.
Go back to Oracle Cloud web UI, go to Virtual Cloud Networks:
There is a vnc
created by default, click on it and next click on the only subnet it has.
There is a section called Security Lists. Click on the only security list and next, click on Add Ingress Rules
and configure the fields as displayed below:
This will allow any TCP connection for 443 port (HTTPS) from any IP address (that is what CIDR means)
Click again on Add Ingress Rules
inside the dialog.
And after this, we finished the configuration for the server.
You can now use the public IP for your instance in your browser to connect to your VS Code web server:
https://PUBLIC_IP
You'll see a warning about a self-signed certificate. That is fine right now, because we don't have a public domain linked to this IP address, and code-server
baked a self-signed one.
Go grab the password specified in~/.config/code-server/config.yaml
inside the VM instance, and paste it in the password field.
Give it a few seconds and then you'll have a complete version of visual studio code running in your browser, with a VM up to 4 cores / 24 GB of RAM 🎉
Hope you find useful this guide, I'll keep posting other uses for your free tier Oracle Cloud, and hope this attracts more people that is starting in the cloud journey.
Posted on November 20, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.