---
title: "Code-server, the VSCode for cloud"
url: "https://vanducng.dev/2019/12/31/Code-server-the-VSCode-for-cloud/"
date: "2019-12-31"
categories: ["DevOps"]
tags: ["docker","tutorial"]
---

# Code-server, the VSCode for cloud

<p align="center"> ![Code-Server](https://vanducng.dev/media/gifs/code-server-login.gif) </p>

Along with the widely cloud adoption, integrated development environment (IDE) on browser is a need to boot developers' productivity. People can collaboratively view, edit and commit on any devices with internet accessed browser. Additionally, you're no longer worry about setting up your local development config. You can consider [Cloud9 (AWS)](https://github.com/c9/core) or paid service like [codeanywhere](https://codeanywhere.com/). 

However, if you are familiar to [Visual Code Studio](https://code.visualstudio.com/), you wish to have a similar web-based IDE to work on a project from your VM instance and you love open source software (OSS), [code-server](https://github.com/cdr/code-server) (with the core of VSCode) is perfectly for you. This project is recently opened sourced by [coder.com](https://coder.com/), we all appreciated that. 

Although original VS Code actually supports [ssh extension](https://code.visualstudio.com/docs/remote/ssh), there is still such pain of  network lagging and proxy policies per my current work. **Code-server** is a better way to go.

After experienced number tutorials, I come up with my owned way which will help to get the code-server up and running as daemon service in about 5 minutes. It is tested on CentOS 7 and Ubuntu 18.04, other Linux distro should be similar.

## Getting started
Depending on targeted OS and code-server version, you can modify the suffix or get the released download link direct from [here](https://github.com/cdr/code-server/releases). 

In this post, I use version **2.1692-vsc1.39.2** for **linux-x86_64**. Download and extract the gz file, then copy binary file **code-server** to executable files location `/bin/`. Remove unnecessary files and folder.

```bash
wget https://github.com/cdr/code-server/releases/download/2.1692-vsc1.39.2/code-server2.1692-vsc1.39.2-linux-x86_64.tar.gz
tar -xvf code-server2.1692-vsc1.39.2-linux-x86_64.tar.gz
rm code-server2.1692-vsc1.39.2-linux-x86_64.tar.gz
cd code-server2.1692-vsc1.39.2-linux-x86_64
sudo cp code-server /bin/
cd ..
rm -rf code-server2.1692-vsc1.39.2-linux-x86_64/
```

Prepare log store location when running code-server in `/var/log/` by creating folder and empty files in advanced. Create **code-server.service** under systemd to make it as a service running in the background.
```bash
mkdir -p /var/log/code-server/
echo > /var/log/code-server/code-server-output.log
echo > /var/log/code-server/code-server-error.log
sudo nano /etc/systemd/system/code-server.service
```

Here is the content of code-server.service, remember the PASSWORD variable to login when code-server is up. As default, it will use port **8080**.

```python
[Unit]
Description=Code Server IDE
After=network.target

[Service]
Type=simple
User=root
Environment="PASSWORD=SecretPassword1"
EnvironmentFile=~/.bashrc
WorkingDirectory=~
Restart=on-failure
RestartSec=10

ExecStart=/bin/code-server $HOME

StandardOutput=file:/var/log/code-server/code-server-output.log
StandardError=file:/var/log/code-server/code-server-error.log

[Install]
WantedBy=multi-user.target
```

One more step to start code-server as a background service and auto start once system reboots. 
```bash
sudo systemctl daemon-reload
sudo systemtl start code-server
sudo systemctl status code-server
```

If code-server status is active then you are good to go. Enable inbound (aka. ingress) traffic for port 8080, and access your IDE with defined PASSWORD previously.

## Desired features
To bring code-server to a new level of cloud IDE for a team, it would be ideal tool if equipped with 2 more features: 

* Security plugin for authentication and authentization management
* Team collaborative features like google docs or office365
