Running code-server on generic app

Hello, I am new here and this may be asked already. However I haven’t found it yet.

Is it possible to create a generic app that can run GitHub - cdr/deploy-code-server: Deploy code-server to the cloud with a few clicks ☁️ 👨🏼‍💻?

I am using digital ocean and I could do it through digital ocean as example they gave. However I am wondering could this be done through generic port app?

1 Like

Hello @titan,

Welcome to the Cleavr forum!

I haven’t tried this yet myself, but from looking at the DO instructions, I believe all you’d need to do is add the provided script as a Quick Script in Cleavr, and then run on your server.

If you give it a try, let us know if that works or not. :slight_smile:

1 Like

Hi buddy,

I did try and I got a strange error that I don’t think its error itself however I could be wrong:


usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-T timeout] [-u user] file ...

######################################################################## 100.0%
                                                                           0.0%
###                                                                        5.3%
#######                                                                   10.4%
##########                                                                14.0%
#############                                                             18.1%
###############                                                           22.1%
##################                                                        26.4%
#####################                                                     30.4%
########################                                                  34.6%
###########################                                               37.8%
##############################                                            43.0%
#################################                                         47.2%
#####################################                                     51.4%
########################################                                  55.6%
###########################################                               59.9%
##############################################                            64.2%
#################################################                         68.5%
####################################################                      72.8%
#####################################################                     74.6%
##########################################################                81.4%
##############################################################            86.1%
#################################################################         90.6%
####################################################################      94.9%
#######################################################################   99.3%
######################################################################## 100.0%
Cloning into 'coder-cloud-redirect-server'...
Created symlink /etc/systemd/system/default.target.wants/code-server@coder.service → /lib/systemd/system/code-server@.service.
Created symlink /etc/systemd/system/multi-user.target.wants/coder-cloud-redirect.service → /etc/systemd/system/coder-cloud-redirect.service.

It is displayed as an error on the generic port app :smiley:

hmmm… I’m not sure what’s going on there. I’ll make some time later to see what’s needed to code server and will post the steps if I’m able to get it to work.

Hi again I thin running it as web-app doesnt work well but as root it did pass, and I updated /root/.config/code-server/config.yaml file with port created by web-app, now it works almost fine.

I am getting:

An unexpected error occurred that requires a reload of this page.

The workbench failed to connect to the server (Error: WebSocket close with status code 1006)

Still trying to figure out what is the problem, maybe missing some stuff.

Okay i figured it out, these 3 lines need to be in the nginx config:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;

Now it works fine and I think locking the web-app with specific users is a good thing as well. Also since its run by root user you should be careful who uses it. Could be possibly done with some other user with limitations per foldder being opened.

Anyway if you figure out how to install/start it as custom non root user, would be nice to share and you can use my findings and create some how to setup post on the forum. Pretty sure people would use it a lot. It would be more secure limiting non root user to some folders where they can use editor on.

Looks like I’m getting the SSL warning as well - even after modifying nginx config. I’ll look Into it some more.

Why do you use a server management tool like Cleavr to install a development environment?
What I understand about Coder is that you install it with Docker on a VPS and that’s all.

I may be the most hated dev right now, but I hate working directly with docker. Always had problems and loving when I don’t need to use it. I set up the coder and its working well :smiley:

Why do you use a server management tool like Cleavr to install a development environment? - Why not? Less work for setting up development and could easily share it with other developers instead of setting everything locally or by myself directly on the server.

1 Like

I’ve made a couple tweaks to the install script. What do you think of the following as a guide?

Step 1 - Add and run coder-server quick script

In the Quick Script section, add a new Quick Script with the following script:

#!/bin/sh

# install code-server service system-wide
export HOME=/root
curl -fsSL https://code-server.dev/install.sh | sh

# add our helper server to redirect to the proper URL for --link
git clone https://github.com/bpmct/coder-cloud-redirect-server
cd coder-cloud-redirect-server
cp coder-cloud-redirect.service /etc/systemd/system/
cp coder-cloud-redirect.py /usr/bin/

# create a code-server user
adduser --disabled-password --gecos "" coder
echo "coder ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/coder
usermod -aG sudo coder

# copy ssh keys from root
cp -r /root/.ssh /home/coder/.ssh
chown -R coder:coder /home/coder/.ssh

# configure code-server for "coder" user
mkdir -p /home/coder/.config/code-server
touch /home/coder/.config/code-server/config.yaml
echo "bind-addr: 127.0.0.1:{{ port }}
auth: password
password: {{ password }}
cert: false" > /home/coder/.config/code-server/config.yaml
chown -R coder:coder /home/coder/.config

# start and enable code-server and our helper service
systemctl enable --now code-server@coder
systemctl enable --now coder-cloud-redirect

Run the Quick Script and add a port number for Code Server to run on as well as a password when prompted.

Expect to see a false-error when script completes its run.

Step 2 - Add and configure Generic Port App

On the server that code-server was installed on, add a new Generic Port App site.

Configure the app with the port number entered when running the script.

Once site is added, click into the site and then go to NGINX Config. Add the following lines to the location / directive:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;

The location / directive should look similar to the following:

location / {
  include cleavr-conf/example.com/*.conf.pre;
  proxy_pass              http://localhost:8585/;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection upgrade;
  proxy_pass_header Server; 
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass_header Server;
  include cleavr-conf/example.com/*.conf.post;
}

Step 3 - Open code-server

Navigate to the URL you used when creating the Generic Port App. You’ll first be prompted to login using the password you’ve added when installing code-server. Add in the password and then continue configure your code-server environment.

1 Like

It is very good in my opinion, you could also add it to the website or make a full script on making it as APP like generic app, nuxt ssr etc. Would be nice to add each separate from Cleavr Documentation but thats up to you.

1 Like

Cool!

I plan to add to our docs / Cleavr Slice. In the future, a one-click install would be pretty killer.

1 Like