diff --git a/deploy-container/README.md b/deploy-container/README.md index 74313588..0ee2c30b 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -4,8 +4,8 @@ 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` @@ -15,7 +15,7 @@ To update your code-server version, modify the version number on line 2 in your 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 @@ -33,14 +33,15 @@ 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 | +| `DOTFILES_REPO` | GitHub path to a dotfiles repository with your personal configuration across devices. | | --- -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. +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. ## 💾 Persist your filesystem with `rclone` @@ -48,7 +49,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 @@ -66,15 +67,20 @@ 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_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. | | | -```sh +``` sh # --- How to use --- @@ -90,8 +96,8 @@ $ sh /home/coder/pull_remote.sh # get latest files from the remote ## 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 diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index a450f3a2..298f654c 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -76,6 +76,26 @@ else fi +# Extract the user's dotfiles, if they exist +if [[ -z "${DOTFILES_REPO}" ]]; then + echo "[$PREFIX] DOTFILES_REPO is not specified" +else + echo "[$PREFIX] DOTFILES_REPO is specified" + git clone $DOTFILES_REPO /home/coder/dotfiles + + # Symlink if install.sh doesn't exist. + # If it exits, run it + if [ -f "/home/coder/dotfiles/install.sh" ]; then + echo "[$PREFIX] install.sh exists, running it..." + /bin/sh /home/coder/dotfiles/install.sh + else + echo "[$PREFIX] install.sh does not exist, symlinking dotfiles..." + ln -sv /home/coder/dotfiles/* ~/ + fi + + +fi + echo "[$PREFIX] Starting code-server..." # Now we can run code-server with the default entrypoint /usr/bin/entrypoint.sh --bind-addr 0.0.0.0:8080 $START_DIR \ No newline at end of file diff --git a/guides/railway.md b/guides/railway.md index e728957e..eb84d079 100644 --- a/guides/railway.md +++ b/guides/railway.md @@ -8,7 +8,7 @@ Use Railway + code-server to get a dev environment that you can access from any ## Step 1: Click button to deploy -[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new?template=https%3A%2F%2Fgithub.com%2Fcdr%2Fdeploy-code-server&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) +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new?template=https%3A%2F%2Fgithub.com%2Fcdr%2Fdeploy-code-server%2F&envs=PASSWORD%2CGIT_REPO%2CDOTFILES_REPO&optionalEnvs=GIT_REPO%2CDOTFILES_REPO&PASSWORDDesc=Your+password+to+log+in+to+code-server+with&GIT_REPODesc=A+git+repo+to+clone+and+open+in+code-server+(ex.+https%3A%2F%2Fgithub.com%2Fcdr%2Fdocs.git)&DOTFILES_REPODesc=Environment+configuration+not+related+to+this+specific+environment.+(see+https%3A%2F%2Fdotfiles.github.io%2F)) ## Step 2: Configure & launch your environment @@ -27,7 +27,7 @@ You also need to specity a `PASSWORD` and a `GIT_REPO` to clone in your environm 1. Open the source repo in GitHub and edit the `Dockerfile` 1. Add some custom tools (like NodeJS) and push to the main branch: - ```Dockerfile +``` Dockerfile # You can add custom software and dependencies for your environment here. Some examples: # RUN code-server --install-extension esbenp.prettier-vscode