diff --git a/README.md b/README.md index 7734787..74055a8 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A collection of one-click buttons and scripts for deploying code-server to vario | Platform | Type | Cheapest Plan | Deploy | | ----------------- | ---------------- | ------------------------------------- | -------------------------------------------------------- | -| DigitalOcean | VM | $5/mo, 1 CPU, 1 GB RAM | Test | -| Vultr | VM | $5/mo, 1 CPU, 1 GB RAM | Test | -| Linode | VM | $3.50/mo, 1 CPU, 512 MB RAM | Test | +| DigitalOcean | VM | $5/mo, 1 CPU, 1 GB RAM | [see guide](guides/digitalocean.md) | +| Vultr | VM | $5/mo, 1 CPU, 1 GB RAM | coming soon | +| Linode | VM | $3.50/mo, 1 CPU, 512 MB RAM | [see guide](guides/linode.md) | | Railway | Deploy Container | Free, specs unknown, but very fast 🚀 | [see guide](guides/railway.md) | | Heroku | Deploy Container | Free, 1 CPU, 512 MB RAM | [see guide](guides/heroku.md) | | Azure App Service | Deploy Container | Free, 1 CPU, 1 GB RAM | [see guide](https://github.com/bencdr/code-server-azure) | diff --git a/deploy-vm/README.md b/deploy-vm/README.md index 4346b13..b74d422 100644 --- a/deploy-vm/README.md +++ b/deploy-vm/README.md @@ -1 +1,5 @@ -yep it is coming +# Deploying `code-server` on a VM + +A simple startup script to run code-server with --link on a VM, designed to run on Ubuntu 20.10. + +**Coming soon:** One-click templates in popular marketplaces. diff --git a/deploy-vm/launch-code-server-linode.sh b/deploy-vm/launch-code-server-linode.sh new file mode 100644 index 0000000..09427c7 --- /dev/null +++ b/deploy-vm/launch-code-server-linode.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# allow us to access systemd logs to see the status of --link +sed -i.bak 's/#Storage=auto/Storage=persistent/' /etc/systemd/journald.conf +mkdir -p /var/log/journal +systemctl force-reload systemd-journald +systemctl restart systemd-journald + +# 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 + +# use a more unique hostname (for Linode) +sudo hostnamectl set-hostname linode-$LINODE_ID +source /root/.bashrc + +# configure code-server to use --link with the "coder" user +mkdir -p /home/coder/.config/code-server +touch /home/coder/.config/code-server/config.yaml +echo "link: true" > /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 code-server@coder +systemctl enable coder-cloud-redirect +systemctl start code-server@coder && systemctl start coder-cloud-redirect \ No newline at end of file diff --git a/deploy-vm/launch-code-server.sh b/deploy-vm/launch-code-server.sh new file mode 100755 index 0000000..6dc05c1 --- /dev/null +++ b/deploy-vm/launch-code-server.sh @@ -0,0 +1,30 @@ +#!/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 to use --link with the "coder" user +mkdir -p /home/coder/.config/code-server +touch /home/coder/.config/code-server/config.yaml +echo "link: true" > /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 \ No newline at end of file diff --git a/guides/digitalocean.md b/guides/digitalocean.md new file mode 100644 index 0000000..fee6ef0 --- /dev/null +++ b/guides/digitalocean.md @@ -0,0 +1,11 @@ +# deploying `code-server` on Linode + +[DigitalOcean](https://digitalocean.com) is an developer-friendly platform with cloud servers. Here is the easiest way to launch code-server on Linode. + +1. Log into DigitalOcean and create a new Ubuntu 20.10 droplet with any size, in any region +1. Under "Select additional options," check `User data`. This will allow you to specify a script that will run on first boot. +1. Paste in the contents of [launch-code-server.sh](../deploy-vm/launch-code-server-linode.sh) to the textarea. +1. Create your server. Feel free to add SSH keys or other preferences. +1. Once your server starts, you can simply navigate to the IP address and get forwarded to a secure version of code-server, which will be proxied behind your GitHub account. For information on how this works, see [code-server --link](https://github.com/cdr/code-server#cloud-program-%EF%B8%8F). + + DigitalOcean launch code-server diff --git a/guides/heroku.md b/guides/heroku.md index 2b40736..67aed57 100644 --- a/guides/heroku.md +++ b/guides/heroku.md @@ -1,6 +1,7 @@ # Guide: Launching `code-server` on Heroku -Heroku is a managed app hosting platform. Launch code-server on Heroku to get on-demand dev environments that turn off when you don't need them! 💵 +Heroku is a managed app hosting platform. +Launch code-server on Heroku to get on-demand dev environments that turn off when you don't need them! 💵 ![code-server and Heroku](../img/heroku-app-create.png) @@ -13,7 +14,9 @@ Heroku is a managed app hosting platform. Launch code-server on Heroku to get on ## Step 2: Configure & deploy your environment `App name`: The URL and you can access code-server with + `PASSWORD`: A password you can use to log in + `GIT_REPO`: The HTTPS URL of a git repo you'd like to use in code-server. (optional) After it has built, you can access it by pressing "View" or "Open app." @@ -22,6 +25,8 @@ After it has built, you can access it by pressing "View" or "Open app." Modify GitHub template +Press the button in the top right of the repo, or or click to [use this template](https://github.com/bpmct/deploy-code-server/generate). + ## Step 4: Set up automatic builds with this repo 1. In Heroku, navigate to `Deploy -> Deployment Method" diff --git a/guides/linode.md b/guides/linode.md new file mode 100644 index 0000000..e1df403 --- /dev/null +++ b/guides/linode.md @@ -0,0 +1,19 @@ +# deploying `code-server` on Linode + +[Linode](https://linode.com) is a developer-friendly platform with cloud servers. Here is the easiest way to launch code-server on Linode. + +1. Log in to Linode and go to the "StackScripts" section in the sidebar + + Linode StackScripts + +1. Navigate to "Community Scripts" and use `bencdr/code-server` or create your own based on [../deploy-vm/launch-code-server-linode.sh](launch-code-server-linode.sh). + +1. Give your server a label and deploy with Ubuntu 20.10 and any size. Once your server starts, you can simply navigate to the IP address and get forwarded to a secure version of code-server, which will be proxied behind your GitHub account. For information on how this works, see [code-server --link](https://github.com/cdr/code-server#cloud-program-%EF%B8%8F). + + Linode launch code-server + +1. Optional: To change the URL in the address bar from `linode-[xxxx]` to something more descriptive, you just need to change your hostname and restart code-server: + ```sh + sudo hostnamectl set-hostname bens-devbox + sudo systemctl restart code-server@coder + ``` diff --git a/guides/railway.md b/guides/railway.md index 805e0a8..f724cbe 100644 --- a/guides/railway.md +++ b/guides/railway.md @@ -1,19 +1,20 @@ # Guide: Launching `code-server` on railway.app -[Railway](https://railway.app) is a new cloud development platform! ☁️ Use Railway + code-server to get a dev environment that you can access from any device. +[Railway](https://railway.app) is a new cloud development platform! ☁️ +Use Railway + code-server to get a dev environment that you can access from any device. ![code-server and railway.app](../img/code-server-railway.png) -## Step 1: Click to deploy +## Step 1: Click button to deploy [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new?template=https%3A%2F%2Fgithub.com%2Fbpmct%2Fcode-server-railway&envs=PASSWORD%2CGIT_REPO&PASSWORDDesc=Your+password+to+log+in+to+code-server+with&GIT_REPODesc=A+git+repo+to+clone+and+open+in+code-server+%28ex.+https%3A%2F%2Fgithub.com%2Fcdr%2Fdocs.git%29) ## Step 2: Configure & launch your environment -![railway launch environment screen](../img/launch-railway.gif) - You'll need to make a new repository which will contain your code-server configuration. If you push changes to this repo (to install NodeJS, for example), it will re-deploy code-server. +Connected git repo + You also need to specity a `PASSWORD` and a `GIT_REPO` to clone in your environment :) ## Step 3: Modify your environment to add additional tools @@ -23,7 +24,7 @@ You also need to specity a `PASSWORD` and a `GIT_REPO` to clone in your environm Connected git repo 1. Open the source repo in GitHub and edit the `Dockerfile` -1. Add some custom tools (like NodeJS) and commit to the main branch: +1. Add some custom tools (like NodeJS) and push to the main branch: ```Dockerfile # You can add custom software and dependencies for your environment here. Some examples: diff --git a/img/add-script-digitalocean.png b/img/add-script-digitalocean.png new file mode 100644 index 0000000..bb4eaba Binary files /dev/null and b/img/add-script-digitalocean.png differ diff --git a/img/digitalocean-launch-code-server.gif b/img/digitalocean-launch-code-server.gif new file mode 100644 index 0000000..fa05bfc Binary files /dev/null and b/img/digitalocean-launch-code-server.gif differ diff --git a/img/linode-launch-code-server.gif b/img/linode-launch-code-server.gif new file mode 100644 index 0000000..0ec0484 Binary files /dev/null and b/img/linode-launch-code-server.gif differ diff --git a/img/linode-stackscripts-sidebar.png b/img/linode-stackscripts-sidebar.png new file mode 100644 index 0000000..e088e40 Binary files /dev/null and b/img/linode-stackscripts-sidebar.png differ