From 6b17676927c2f68168059125d85060b264f7e411 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 12 Mar 2021 15:36:01 +0000 Subject: [PATCH 01/18] make START_DIR configurable --- deploy-container/README.md | 12 ++++++------ deploy-container/entrypoint.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deploy-container/README.md b/deploy-container/README.md index 02db877e..2355eb36 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -13,12 +13,12 @@ Docker Hub: `bencdr/code-server-deploy-container` ## Environment variables: -| Variable Name | Description | Default Value | -| ------------- | ---------------------------------------------------------- | ------------- | +| Variable Name | Description | Default Value | +| ------------- | ---------------------------------------------------------- | ------------------- | | `PASSWORD` | Password for code-server | -| `USE_LINK` | Use code-server --link instead of a password (coming soon) | false | -| `GIT_REPO` | A git repository to clone | | - +| `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 | --- ## 💾 Persist your filesystem with `rclone` @@ -44,7 +44,7 @@ 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_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 | | diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index d8db0ffb..74fac968 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -START_DIR=/home/coder/project +START-DIR="${START_DIR:-/home/coder/project}" # add rclone config and start rclone, if supplied if [[ -z "${RCLONE_DATA}" ]]; then From 4a66224b2bff2d2e4dc5f51ae9f6cd4527d39fd4 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 19:39:26 +0000 Subject: [PATCH 02/18] fix permissions order --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1c4edf5..38a3d17d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,15 +13,15 @@ ENV SHELL=/bin/bash RUN sudo apt-get update && sudo apt-get install unzip -y RUN curl https://rclone.org/install.sh | sudo bash +# Fix permissions for code-server +RUN sudo chown -R coder:coder /home/coder/.local + # You can add custom software and dependencies for your environment here. Some examples: # RUN code-server --install-extension esbenp.prettier-vscode # RUN sudo apt-get install -y build-essential # RUN COPY myTool /home/coder/myTool -# Fix permissions for code-server -RUN sudo chown -R coder:coder /home/coder/.local - # Port ENV PORT=8080 From ed0b599806be5f7e084f9ff493fd4e94d735ee95 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 19:44:31 +0000 Subject: [PATCH 03/18] fix start dir bug --- deploy-container/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index 74fac968..9202747a 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -START-DIR="${START_DIR:-/home/coder/project}" +START_DIR="${START_DIR:-/home/coder/project}" # add rclone config and start rclone, if supplied if [[ -z "${RCLONE_DATA}" ]]; then From c87abcbcfbc0272aa8fb3416678ba5f83159fcd4 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 19:47:38 +0000 Subject: [PATCH 04/18] fix logic --- deploy-container/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index 9202747a..c9dfd633 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -7,7 +7,7 @@ if [[ -z "${RCLONE_DATA}" ]]; then echo "RCLONE_DATA is not specified. Files will not persist" # Clone the git repo, if it exists - [ -z "${GIT_REPO}" ] && echo "No GIT_REPO specified"; git clone $GIT_REPO $START_DIR + [ -z "${GIT_REPO}" ] && echo "No GIT_REPO specified" || git clone $GIT_REPO $START_DIR else echo "Copying rclone config..." From cab263d61f8ba8952a803c948478a0cf5ef634ac Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 19:49:53 +0000 Subject: [PATCH 05/18] make START_DIR --- deploy-container/entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index c9dfd633..3c91be19 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -2,12 +2,14 @@ START_DIR="${START_DIR:-/home/coder/project}" +mkdir -p $START_DIR + # add rclone config and start rclone, if supplied if [[ -z "${RCLONE_DATA}" ]]; then - echo "RCLONE_DATA is not specified. Files will not persist" + echo "[Note] RCLONE_DATA is not specified. Files will not persist" # Clone the git repo, if it exists - [ -z "${GIT_REPO}" ] && echo "No GIT_REPO specified" || git clone $GIT_REPO $START_DIR + [ -z "${GIT_REPO}" ] && echo "[Note] No GIT_REPO specified"; || git clone $GIT_REPO $START_DIR else echo "Copying rclone config..." @@ -29,7 +31,7 @@ else else # we need to clone the git repo and sync echo "Pushing initial files to remote..." - [ -z "${GIT_REPO}" ] && echo "No GIT_REPO specified" && mkdir -p $START_DIR && echo "intial file" > $START_DIR/file.txt; git clone $GIT_REPO $START_DIR + [ -z "${GIT_REPO}" ] && echo "No GIT_REPO specified" && echo "intial file" > $START_DIR/file.txt; git clone $GIT_REPO $START_DIR /home/coder/push_remote.sh& fi From e2acb348490cbd1e4e995a00507ce9e925cd2292 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 19:51:45 +0000 Subject: [PATCH 06/18] cool loggins --- deploy-container/entrypoint.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index 3c91be19..e9d7844e 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -2,17 +2,19 @@ START_DIR="${START_DIR:-/home/coder/project}" +PREFIX="deploy-code-server" + mkdir -p $START_DIR # add rclone config and start rclone, if supplied if [[ -z "${RCLONE_DATA}" ]]; then - echo "[Note] RCLONE_DATA is not specified. Files will not persist" + echo "[$PREFIX] RCLONE_DATA is not specified. Files will not persist" # Clone the git repo, if it exists - [ -z "${GIT_REPO}" ] && echo "[Note] No GIT_REPO specified"; || git clone $GIT_REPO $START_DIR + [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" || git clone $GIT_REPO $START_DIR else - echo "Copying rclone config..." + echo "[$PREFIX] Copying rclone config..." mkdir -p /home/coder/.config/rclone/ touch /home/coder/.config/rclone/rclone.conf echo $RCLONE_DATA | base64 -d > /home/coder/.config/rclone/rclone.conf @@ -26,12 +28,12 @@ else if rclone ls $RCLONE_REMOTE_PATH; then # grab the files from the remote instead of re-cloning the git repo - echo "Pulling existing files from remote..." + echo "[$PREFIX] Pulling existing files from remote..." /home/coder/pull_remote.sh& else # we need to clone the git repo and sync - echo "Pushing initial files to remote..." - [ -z "${GIT_REPO}" ] && echo "No GIT_REPO specified" && echo "intial file" > $START_DIR/file.txt; git clone $GIT_REPO $START_DIR + echo "[$PREFIX] Pushing initial files to remote..." + [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" && echo "Have questions? Join us at https://community.coder.com" > $START_DIR/file.txt; git clone $GIT_REPO $START_DIR /home/coder/push_remote.sh& fi From 4c4fa1a125f308d99780a2645a60eaad6d60cc38 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 19:59:07 +0000 Subject: [PATCH 07/18] reuse clone function --- deploy-container/entrypoint.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index e9d7844e..86f664fa 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -6,12 +6,17 @@ PREFIX="deploy-code-server" mkdir -p $START_DIR +# function to clone the git repo or add a user's first file if no repo was specified. +project_init () { + [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" && echo "Example file. Have questions? Join us at https://community.coder.com" > $START_DIR/coder.txt | git clone $GIT_REPO $START_DIR +} + # add rclone config and start rclone, if supplied if [[ -z "${RCLONE_DATA}" ]]; then echo "[$PREFIX] RCLONE_DATA is not specified. Files will not persist" - # Clone the git repo, if it exists - [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" || git clone $GIT_REPO $START_DIR + # start the project + project_init() else echo "[$PREFIX] Copying rclone config..." @@ -27,17 +32,18 @@ else chmod +x push_remote.sh pull_remote.sh if rclone ls $RCLONE_REMOTE_PATH; then - # grab the files from the remote instead of re-cloning the git repo + # grab the files from the remote instead of running project_init() echo "[$PREFIX] Pulling existing files from remote..." /home/coder/pull_remote.sh& else # we need to clone the git repo and sync echo "[$PREFIX] Pushing initial files to remote..." - [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" && echo "Have questions? Join us at https://community.coder.com" > $START_DIR/file.txt; git clone $GIT_REPO $START_DIR + project_init() /home/coder/push_remote.sh& 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 From cd4060fd4a70064ca9f69869c6effe0a7f983839 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 20:00:04 +0000 Subject: [PATCH 08/18] i'm a bash noob --- deploy-container/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index 86f664fa..16c9bdf0 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -16,7 +16,7 @@ if [[ -z "${RCLONE_DATA}" ]]; then echo "[$PREFIX] RCLONE_DATA is not specified. Files will not persist" # start the project - project_init() + project_init else echo "[$PREFIX] Copying rclone config..." @@ -38,7 +38,7 @@ else else # we need to clone the git repo and sync echo "[$PREFIX] Pushing initial files to remote..." - project_init() + project_init /home/coder/push_remote.sh& fi From 935800a08849fa6b97edd19e875dd274684f547b Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 20:00:44 +0000 Subject: [PATCH 09/18] even more of a bash noob --- deploy-container/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index 16c9bdf0..4bff555c 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -8,7 +8,7 @@ mkdir -p $START_DIR # function to clone the git repo or add a user's first file if no repo was specified. project_init () { - [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" && echo "Example file. Have questions? Join us at https://community.coder.com" > $START_DIR/coder.txt | git clone $GIT_REPO $START_DIR + [ -z "${GIT_REPO}" ] && echo "[$PREFIX] No GIT_REPO specified" && echo "Example file. Have questions? Join us at https://community.coder.com" > $START_DIR/coder.txt || git clone $GIT_REPO $START_DIR } # add rclone config and start rclone, if supplied From 8e51dce01146302def562bb88b74aad61e4d1042 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 20:38:50 +0000 Subject: [PATCH 10/18] add hashed info --- deploy-container/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/deploy-container/README.md b/deploy-container/README.md index 2355eb36..705f5e2e 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -13,12 +13,13 @@ Docker Hub: `bencdr/code-server-deploy-container` ## Environment variables: -| Variable Name | Description | Default Value | -| ------------- | ---------------------------------------------------------- | ------------------- | -| `PASSWORD` | Password for code-server | -| `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 | +| Variable Name | Description | Default Value | +| ----------------- | ------------------------------------------------------------------------------------------------ | ------------------- | +| `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 | --- ## 💾 Persist your filesystem with `rclone` From 0158e890ffc113cd78566e0e979c686305d21ee7 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 20:49:44 +0000 Subject: [PATCH 11/18] add ability to add tasks --- Dockerfile | 3 +++ deploy-container/entrypoint.sh | 4 ++++ deploy-container/rclone-tasks.json | 33 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 deploy-container/rclone-tasks.json diff --git a/Dockerfile b/Dockerfile index 38a3d17d..8bc3cf22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,9 @@ ENV SHELL=/bin/bash RUN sudo apt-get update && sudo apt-get install unzip -y RUN curl https://rclone.org/install.sh | sudo bash +# Copy rclone tasks to /tmp, to potentially be used +COPY deploy-container/tasks.json /tmp/tasks.json + # Fix permissions for code-server RUN sudo chown -R coder:coder /home/coder/.local diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index 4bff555c..c65e63aa 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -18,6 +18,10 @@ if [[ -z "${RCLONE_DATA}" ]]; then # start the project project_init + # copy our tasks config to VS Code + echo "[$PREFIX] Copying VS Code tasks config" + cp /tmp/tasks.json /home/coder/.local/share/code-server/User/tasks.json + else echo "[$PREFIX] Copying rclone config..." mkdir -p /home/coder/.config/rclone/ diff --git a/deploy-container/rclone-tasks.json b/deploy-container/rclone-tasks.json new file mode 100644 index 00000000..1ccefca3 --- /dev/null +++ b/deploy-container/rclone-tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "push_remote", + "type": "shell", + "command": "sh /home/coder/push_remote.sh", + "presentation": { + "reveal": "always" + }, + "problemMatcher": [], + "options": { + "statusbar": { + "label": "$(repo-push) push" + } + } + }, + { + "label": "pull_remote", + "type": "shell", + "command": "sh /home/coder/pull_remote.sh", + "presentation": { + "reveal": "always" + }, + "problemMatcher": [], + "options": { + "statusbar": { + "label": "$(repo-pull) pull" + } + } + } + ] +} \ No newline at end of file From bfa9c95d03ff7e4a03002b118df4d1a0941ba949 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 20:56:29 +0000 Subject: [PATCH 12/18] add vs code instructions for task --- deploy-container/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy-container/README.md b/deploy-container/README.md index 705f5e2e..db4d2fad 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -52,11 +52,14 @@ Now, you can add the following the environment variables in the code-server clou ```sh -# How to use: +# --- How to use --- +# Terminal: $ 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: +# ctrl + P, run task: push_remote or pull_remote ``` --- From e99598487be12675ddc5d43bd8813bcc3fdf8f1b Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 21:02:27 +0000 Subject: [PATCH 13/18] rclone fix --- Dockerfile | 2 +- deploy-container/entrypoint.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8bc3cf22..8e47cafc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN sudo apt-get update && sudo apt-get install unzip -y RUN curl https://rclone.org/install.sh | sudo bash # Copy rclone tasks to /tmp, to potentially be used -COPY deploy-container/tasks.json /tmp/tasks.json +COPY deploy-container/rclone-tasks.json /tmp/rclone-tasks.json # Fix permissions for code-server RUN sudo chown -R coder:coder /home/coder/.local diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index c65e63aa..b0bda052 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -18,16 +18,16 @@ if [[ -z "${RCLONE_DATA}" ]]; then # start the project project_init - # copy our tasks config to VS Code - echo "[$PREFIX] Copying VS Code tasks config" - cp /tmp/tasks.json /home/coder/.local/share/code-server/User/tasks.json - else echo "[$PREFIX] Copying rclone config..." mkdir -p /home/coder/.config/rclone/ touch /home/coder/.config/rclone/rclone.conf echo $RCLONE_DATA | base64 -d > /home/coder/.config/rclone/rclone.conf + # copy our tasks config to VS Code + echo "[$PREFIX] Applying VS Code tasks config for rclone" + cp /tmp/rclone-tasks.json /home/coder/.local/share/code-server/User/tasks.json + # Full path to the remote filesystem RCLONE_REMOTE_PATH=${RCLONE_REMOTE_NAME:-code-server-remote}:${RCLONE_DESTINATION:-code-server-files} RCLONE_SOURCE_PATH=${RCLONE_SOURCE:-$START_DIR} From 45c63b9939b3afa9c33d5bb02067aad13708d9cd Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 21:45:25 +0000 Subject: [PATCH 14/18] document vscode tasks --- deploy-container/README.md | 2 +- deploy-container/entrypoint.sh | 18 +++++++++++++++--- img/rclone-vscode-tasks.png | Bin 0 -> 6595 bytes 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 img/rclone-vscode-tasks.png diff --git a/deploy-container/README.md b/deploy-container/README.md index db4d2fad..a378fe9f 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -49,7 +49,7 @@ Now, you can add the following the environment variables in the code-server clou | 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 | ```sh # --- How to use --- diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index b0bda052..f2bef595 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -24,9 +24,21 @@ else touch /home/coder/.config/rclone/rclone.conf echo $RCLONE_DATA | base64 -d > /home/coder/.config/rclone/rclone.conf - # copy our tasks config to VS Code - echo "[$PREFIX] Applying VS Code tasks config for rclone" - cp /tmp/rclone-tasks.json /home/coder/.local/share/code-server/User/tasks.json + # defasult to true + RCLONE_VSCODE_TASKS="${RCLONE_VSCODE_TASKS:-true}" + + if [ $RCLONE_VSCODE_TASKS = "true" ]; then + # copy our tasks config to VS Code + echo "[$PREFIX] Applying VS Code tasks for rclone" + cp /tmp/rclone-tasks.json /home/coder/.local/share/code-server/User/tasks.json + # install the extension to add to menu bar + code-server --install-extension actboy168.tasks& + else + # user specified they don't want to apply the tasks + echo "[$PREFIX] Skipping VS Code tasks for rclone" + fi + + # Full path to the remote filesystem RCLONE_REMOTE_PATH=${RCLONE_REMOTE_NAME:-code-server-remote}:${RCLONE_DESTINATION:-code-server-files} diff --git a/img/rclone-vscode-tasks.png b/img/rclone-vscode-tasks.png new file mode 100644 index 0000000000000000000000000000000000000000..7636887078a76d0cfbf198463c59021781b6826d GIT binary patch literal 6595 zcma)9WmH_-l5QLtLK>Gwn*?_Vu8jr@5ZoOahlb#8K|^qwARz%laBT?g?(QLYf(0i8 z7;@j6`|g^VA9L2KQ+0NIU)8SKYp+!&T3t=y5s(r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Oo6uGL?9qZ5dF+B`hM@DYWtcq=-i4k-Y&*dlByCec&d+04!=%uv#Wuw!R%b6)+6bo8r`le5$`FClukL~%&x;X z16AI6dKYG%PxYBg4jM%@bmEE�&-v;CCM>NgRA=eJct|8y;`XB3?-R*me1+RMa4n zW2nX1yf1c9&nNU-K?8L3SlK{FIl}Owzbv*Sdad#kSxET}ZuI5BYO33=`lz zmhs(3B`6g!%R{0|VN}Ozl0TNbv=mFJhETz5F~|%(rIVFM9h)5c&(v&@X7CyM;7fX# r+(SU>KnFUT;sVw`5Q_gBaz&dTgUTFCYw`Whui|q#HQ92gS?GTOWMMT+ literal 0 HcmV?d00001 From ba362546217291cde49d7e593591173a79f832b5 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 14 Mar 2021 21:48:33 +0000 Subject: [PATCH 15/18] fix labels --- deploy-container/rclone-tasks.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy-container/rclone-tasks.json b/deploy-container/rclone-tasks.json index 1ccefca3..d095796d 100644 --- a/deploy-container/rclone-tasks.json +++ b/deploy-container/rclone-tasks.json @@ -11,7 +11,7 @@ "problemMatcher": [], "options": { "statusbar": { - "label": "$(repo-push) push" + "label": "$(repo-push) rclone: push" } } }, @@ -25,7 +25,7 @@ "problemMatcher": [], "options": { "statusbar": { - "label": "$(repo-pull) pull" + "label": "$(repo-pull) rclone: pull" } } } From b96f1de1858bca8115df81db272ec8d0ad8c80c6 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 15 Mar 2021 04:45:49 +0000 Subject: [PATCH 16/18] mention additional variables --- guides/heroku.md | 2 ++ guides/railway.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/guides/heroku.md b/guides/heroku.md index e07ee2d9..d7968c4c 100644 --- a/guides/heroku.md +++ b/guides/heroku.md @@ -50,3 +50,5 @@ Press the button in the top right of the repo, or or click to [use this template 1. Head back to Heroku and notice a new deployment has started. After it has completed, you can use these tools in your environment. 1. (Optional): [Configure rclone](https://github.com/cdr/deploy-code-server/tree/main/deploy-container#-persist-your-filesystem-with-rclone) so that you can save your VS Code config and files without commiting + +See the [deploy-container README](../deploy-container) for other config vars for your environment. \ No newline at end of file diff --git a/guides/railway.md b/guides/railway.md index fe41fdc2..ae0d4b53 100644 --- a/guides/railway.md +++ b/guides/railway.md @@ -42,3 +42,5 @@ You also need to specity a `PASSWORD` and a `GIT_REPO` to clone in your environm 1. Head back to Railway and notice a new deployment was created. After it has completed, you can use these tools in your environment. 1. (Optional): [Configure rclone](https://github.com/cdr/deploy-code-server/tree/main/deploy-container#-persist-your-filesystem-with-rclone) so that you can save your VS Code config and files without commiting + +See the [deploy-container README](../deploy-container) for other config vars for your environment. \ No newline at end of file From 1c703a450855fd15430b6ea282c7ef06f77ebd7c Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 15 Mar 2021 20:23:11 +0000 Subject: [PATCH 17/18] add better docs for dev tools --- Dockerfile | 15 ++++++++++++--- deploy-container/README.md | 4 +++- deploy-container/myTool/test.sh | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 deploy-container/myTool/test.sh diff --git a/Dockerfile b/Dockerfile index 8e47cafc..173eec7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,11 +19,20 @@ COPY deploy-container/rclone-tasks.json /tmp/rclone-tasks.json # Fix permissions for code-server RUN sudo chown -R coder:coder /home/coder/.local -# You can add custom software and dependencies for your environment here. Some examples: +# You can add custom software and dependencies for your environment below +# ----------- +# 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 -# RUN sudo apt-get install -y build-essential -# RUN COPY myTool /home/coder/myTool + +# Install apt packages: +# RUN sudo apt-get install -y ubuntu-make + +# Copy files: +# COPY deploy-container/myTool /home/coder/myTool + +# ----------- # Port ENV PORT=8080 diff --git a/deploy-container/README.md b/deploy-container/README.md index a378fe9f..7b16ec2a 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -22,6 +22,8 @@ Docker Hub: `bencdr/code-server-deploy-container` | `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. + ## 💾 Persist your filesystem with `rclone` This image has built-in support for [rclone](https://rclone.org/) so that your files don't get lost when code-server is re-deployed. @@ -49,7 +51,7 @@ Now, you can add the following the environment variables in the code-server clou | 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 | ```sh # --- How to use --- diff --git a/deploy-container/myTool/test.sh b/deploy-container/myTool/test.sh new file mode 100644 index 00000000..2cea5b72 --- /dev/null +++ b/deploy-container/myTool/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "This is a demo tool that could be brought into the code-server workspace" \ No newline at end of file From 28f2ccc4dbfa9fa5665d3afba2233dae7a880233 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 15 Mar 2021 20:38:07 +0000 Subject: [PATCH 18/18] support rclone flags --- deploy-container/README.md | 3 +++ deploy-container/entrypoint.sh | 34 +++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/deploy-container/README.md b/deploy-container/README.md index 7b16ec2a..02f46757 100644 --- a/deploy-container/README.md +++ b/deploy-container/README.md @@ -52,6 +52,9 @@ Now, you can add the following the environment variables in the code-server clou | 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_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 # --- How to use --- diff --git a/deploy-container/entrypoint.sh b/deploy-container/entrypoint.sh index f2bef595..a450f3a2 100755 --- a/deploy-container/entrypoint.sh +++ b/deploy-container/entrypoint.sh @@ -26,6 +26,8 @@ else # defasult to true RCLONE_VSCODE_TASKS="${RCLONE_VSCODE_TASKS:-true}" + RCLONE_AUTO_PUSH="${RCLONE_AUTO_PUSH:-true}" + RCLONE_AUTO_PULL="${RCLONE_AUTO_PULL:-true}" if [ $RCLONE_VSCODE_TASKS = "true" ]; then # copy our tasks config to VS Code @@ -43,19 +45,33 @@ else # Full path to the remote filesystem RCLONE_REMOTE_PATH=${RCLONE_REMOTE_NAME:-code-server-remote}:${RCLONE_DESTINATION:-code-server-files} RCLONE_SOURCE_PATH=${RCLONE_SOURCE:-$START_DIR} - echo "rclone sync $RCLONE_SOURCE_PATH $RCLONE_REMOTE_PATH -vv" > /home/coder/push_remote.sh - echo "rclone sync $RCLONE_REMOTE_PATH $RCLONE_SOURCE_PATH -vv" > /home/coder/pull_remote.sh + echo "rclone sync $RCLONE_SOURCE_PATH $RCLONE_REMOTE_PATH $RCLONE_FLAGS -vv" > /home/coder/push_remote.sh + echo "rclone sync $RCLONE_REMOTE_PATH $RCLONE_SOURCE_PATH $RCLONE_FLAGS -vv" > /home/coder/pull_remote.sh chmod +x push_remote.sh pull_remote.sh if rclone ls $RCLONE_REMOTE_PATH; then - # grab the files from the remote instead of running project_init() - echo "[$PREFIX] Pulling existing files from remote..." - /home/coder/pull_remote.sh& + + if [ $RCLONE_AUTO_PULL = "true" ]; then + # grab the files from the remote instead of running project_init() + echo "[$PREFIX] Pulling existing files from remote..." + /home/coder/pull_remote.sh& + else + # user specified they don't want to apply the tasks + echo "[$PREFIX] Auto-pull is disabled" + fi + else - # we need to clone the git repo and sync - echo "[$PREFIX] Pushing initial files to remote..." - project_init - /home/coder/push_remote.sh& + + if [ $RCLONE_AUTO_PUSH = "true" ]; then + # we need to clone the git repo and sync + echo "[$PREFIX] Pushing initial files to remote..." + project_init + /home/coder/push_remote.sh& + else + # user specified they don't want to apply the tasks + echo "[$PREFIX] Auto-push is disabled" + fi + fi fi