# Creating a new Coding Server

# Instalaltion

Install code-server

Copy the content of https://github.com/coder/code-server/blob/main/install.sh and run it

nano install-code-server.sh
chmod +x install-code-server.sh
./install-code-server.sh
sudo systemctl enable --now code-server@root

Install NGINX

sudo apt update
sudo apt install -y nginx certbot python3-certbot-nginx

# Configuration

Update /etc/nginx/sites-available/code-server using sudo with the following configuration

nano /etc/nginx/sites-available/code-server
server {
    listen 80;
    listen [::]:80;
    server_name coding.cyberocean.tn;

    location / {
      proxy_pass http://localhost:8080/;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
    }
}

Enable the config

sudo ln -s ../sites-available/code-server /etc/nginx/sites-enabled/code-server

Create SSL

certbot --non-interactive --redirect --agree-tos --nginx -d coding.cyberocean.tn -m khacloud.saas@gmail.com

Create the folders

mkdir /var/khacloud
mkdir /var/khacloud/projects

Create a password for the code server

nano .config/code-server/config.yaml

set the following

bind-addr: 127.0.0.1:8080
auth: password
password: <PASSWORD_HERE>
cert: false

Set Git credentials

nano .git-credentials

set the following

https://cyberocean-saas:<TOKEN_HERE>@github.com

Create the Git configs

nano .gitconfig

set the following

[user]
        email = clear
        name = cyberocean-saas
[credential]
        helper = store
[pull]
        rebase = false

# Projects Transfer

If you have files to transfer connect from the server that contains the files/folders and run this command

rsync -avz /path/to/folder_x/ root@<CODING_SERVER_IP_ADDRESS>:/path/to/folder_x/