From cecaa7dc8d994ad40308e3fe45694ce9ab91c24d Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Tue, 29 Jun 2021 23:44:34 -0400 Subject: [PATCH 1/3] add instructions for running locally --- deploy-container/README.md | 54 +++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/deploy-container/README.md b/deploy-container/README.md index 46b99a2e..04348a5e 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -4,18 +4,29 @@ An container image built for deploying code-server. ## Guides -* [Deploy on Railway](../guides/railway.md) -* [Deploy on Heroku](../guides/heroku.md) +- [Deploy on Railway](../guides/railway.md) +- [Deploy on Heroku](../guides/heroku.md) Docker Hub: `bencdr/code-server-deploy-container` +To run the container locally, you can use: + +``` +docker run -p 127.0.0.1:8080:8080 \ + -v "$PWD/project:/home/coder/project" \ + -u "$(id -u):$(id -g)" \ + -e "DOCKER_USER=$USER" \ + -e "PASSWORD=12345" \ + -it bencdr/code-server-deploy-container:latest +``` + ## Modifying your code-server environment To update your code-server version, modify the version number on line 2 in your Dockerfile. See the [list of tags](https://hub.docker.com/r/codercom/code-server/tags?page=1&ordering=last_updated) for the latest version. We've included some examples on how to add additoonal dependencies in the root-level [Dockerfile](../Dockerfile): -``` Dockerfile +```Dockerfile # Install a VS Code extension: # Note: we use a different marketplace than VS Code. See https://github.com/cdr/code-server/blob/main/docs/FAQ.md#differences-compared-to-vs-code RUN code-server --install-extension esbenp.prettier-vscode @@ -23,7 +34,7 @@ RUN code-server --install-extension esbenp.prettier-vscode # Install apt packages: RUN sudo apt-get install -y ubuntu-make -# Copy files: +# Copy files: COPY deploy-container/myTool /home/coder/myTool ``` @@ -33,11 +44,12 @@ COPY deploy-container/myTool /home/coder/myTool | Variable Name | Description | Default Value | | ----------------- | ------------------------------------------------------------------------------------------------ | ------------------- | -| `PASSWORD` | Password for code-server | | +| `PASSWORD` | Password for code-server | | | `HASHED_PASSWORD` | Overrrides PASSWORD. [SHA-256 hash](https://xorbin.com/tools/sha256-hash-calculator) of password | -| `USE_LINK` | Use code-server --link instead of a password (coming soon) | false | -| `GIT_REPO` | A git repository to clone | | -| `START_DIR` | The directory code-server opens (and clones repos in) | /home/coder/project | +| `USE_LINK` | Use code-server --link instead of a password (coming soon) | false | +| `GIT_REPO` | A git repository to clone | | +| `START_DIR` | The directory code-server opens (and clones repos in) | /home/coder/project | + --- Other code-server environment variables (such as `CODE_SERVER_CONFIG` ) can also be used. See the [code-server FAQ](https://github.com/cdr/code-server/blob/main/docs/FAQ.md) for details. @@ -48,7 +60,7 @@ This image has built-in support for [rclone](https://rclone.org/) so that your f You can generate the rclone config on any machine, but it works great on the code-server environment itself, or Google Cloud Shell :) -``` sh +```sh # 1. install rclone # see https://rclone.org/install/ for other install options $ curl https://rclone.org/install.sh | sudo bash @@ -65,16 +77,16 @@ Now, you can add the following the environment variables in the code-server clou | Environment Variable | Description | Default Value | Required | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | -------- | -| RCLONE_DATA | the encoded rclone config you copied in step 3 | n/a | ✅ | -| RCLONE_REMOTE_NAME | the name of the remote you added in step 2.
check with `$ rclone listremotes` | code-server-remote | | +| RCLONE_DATA | the encoded rclone config you copied in step 3 | n/a | ✅ | +| RCLONE_REMOTE_NAME | the name of the remote you added in step 2.
check with `$ rclone listremotes` | code-server-remote | | | RCLONE_SOURCE | source directory to sync files in the code-server container | the project directory: `/home/coder/project` | | | RCLONE_DESTINATION | the path in the remote that rclone syncs to. change this if you have multiple code-server environments, or if you want to better organize your files. | code-server-files | | -| RCLONE_VSCODE_TASKS | import push and pull shortcuts into VS Code ![rclone screenshot from VS Code](../img/rclone-vscode-tasks.png) | true | +| RCLONE_VSCODE_TASKS | import push and pull shortcuts into VS Code ![rclone screenshot from VS Code](../img/rclone-vscode-tasks.png) | true | | RCLONE_AUTO_PUSH | automatically push files on startup if the rclone remote is empty (environment -> rclone remote) | true | | | RCLONE_AUTO_PULL | automatically pull files on startup if the rclone remote is not empty (rclone -> environment remote) | true | | -| RCLONE_FLAGS | additional flags to attach to the push and pull script.
type `$ rclone help flags` for a list. | | | +| RCLONE_FLAGS | additional flags to attach to the push and pull script.
type `$ rclone help flags` for a list. | | | -``` sh +```sh # --- How to use --- @@ -83,14 +95,14 @@ $ sh /home/coder/push_remote.sh # save your uncomitted files to the remote $ sh /home/coder/pull_remote.sh # get latest files from the remote # In VS Code: -# use items in bottom bar or ctrl + P, run task: push_remote or pull_remote or +# use items in bottom bar or ctrl + P, run task: push_remote or pull_remote or ``` ### Popular rclone flags To avoid syncing unnecessary directories, add this to `RCLONE_FLAGS` : -``` none +```none --exclude "node_modules/**" --exclude ".git/**" ``` @@ -98,8 +110,8 @@ To avoid syncing unnecessary directories, add this to `RCLONE_FLAGS` : ## Todo -* [ ] Make `push_remote` and `pull_remote` commands in path -* [ ] Impliment file watcher or auto file sync in VS Code -* [ ] Attach a "push" on a git stash?? -* [ ] Add support for SSH / VS Code remote access -* [ ] Make rclone logs visible in environment for debugging +- [ ] Make `push_remote` and `pull_remote` commands in path +- [ ] Impliment file watcher or auto file sync in VS Code +- [ ] Attach a "push" on a git stash?? +- [ ] Add support for SSH / VS Code remote access +- [ ] Make rclone logs visible in environment for debugging From 84301bbd90811fa6634a778697ce8dda6bc74223 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Tue, 29 Jun 2021 23:46:29 -0400 Subject: [PATCH 2/3] name code block --- deploy-container/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy-container/README.md b/deploy-container/README.md index 92f41bb1..40e9a008 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -11,7 +11,7 @@ Docker Hub: `bencdr/code-server-deploy-container` To run the container locally, you can use: -``` +```console docker run -p 127.0.0.1:8080:8080 \ -v "$PWD/project:/home/coder/project" \ -u "$(id -u):$(id -g)" \ From 91ce66bab8d9ef8628f59e72a23290cff5fa8c41 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Tue, 13 Jul 2021 09:54:05 -0400 Subject: [PATCH 3/3] add troubleshooting steps --- deploy-vm/README.md | 35 ++++++++++++++++++++++++++++++++--- guides/aws-ec2.md | 2 ++ guides/digitalocean.md | 2 ++ guides/linode.md | 3 +++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/deploy-vm/README.md b/deploy-vm/README.md index 3232fea1..71d2a4e3 100644 --- a/deploy-vm/README.md +++ b/deploy-vm/README.md @@ -4,11 +4,40 @@ A simple startup script to run code-server with --link on a VM, designed to run **Coming soon:** One-click templates in popular marketplaces. -## In this repo: +## In this repo - [launch-code-server.sh](./launch-code-server.sh) - Command tested on Ubuntu machines (uses --link) - [launch-linode.sh](./launch-linode.sh) - launch-code-server.sh adapted for Linode -## Other scripts: +## Troubleshooting -- [code-server, CloudFlare, and Caddy](https://github.com/alec-hs/coder-cloudflare-setup): Sets up code-server and configures CloudFlare DNS +- Ensure you have port 80 open on your server's firewall + +- SSH or use the built-in console to connect to your workspace + + 1. Check the code-server status + + ```console + systemctl status code-server@coder + + # if not working: + systemctl restart code-server@coder + ``` + + 1. Ensure journalctl is capturing logs + + ```console + journalctl -u code-server@coder + ``` + + 1. Ensure the HTTP redirect server is working + + ```console + systemctl status coder-cloud-redirect + + # systemctl restart coder-cloud-redirect + ``` + +## Other scripts + +- [code-server, CloudFlare, and Caddy](https://github.com/alec-hs/coder-cloudflare-setup): Sets up code-server and configures CloudFlare DNS diff --git a/guides/aws-ec2.md b/guides/aws-ec2.md index 9ca1c211..f9361abc 100644 --- a/guides/aws-ec2.md +++ b/guides/aws-ec2.md @@ -28,3 +28,5 @@ sudo hostnamectl set-hostname bens-devbox sudo systemctl restart code-server@coder ``` + +See our [troubleshooting guide](../deploy-vm#troubleshooting) if you are unable to connect after some time. diff --git a/guides/digitalocean.md b/guides/digitalocean.md index f19a35b5..3cad2c97 100644 --- a/guides/digitalocean.md +++ b/guides/digitalocean.md @@ -11,3 +11,5 @@ 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 + +See our [troubleshooting guide](../deploy-vm#troubleshooting) if you are unable to connect after some time. diff --git a/guides/linode.md b/guides/linode.md index d4aefd4e..8af0a5c0 100644 --- a/guides/linode.md +++ b/guides/linode.md @@ -13,7 +13,10 @@ 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 ``` + +See our [troubleshooting guide](../deploy-vm#troubleshooting) if you are unable to connect after some time.