Skip to content

Commit df02690

Browse files
committed
begin refactor
1 parent 10bca02 commit df02690

File tree

7 files changed

+108
-55
lines changed

7 files changed

+108
-55
lines changed

.github/workfows/to-docker-hub.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to Docker Hub
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
jobs:
8+
push_to_registry:
9+
name: Push Docker image to Docker Hub
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out the repo
13+
uses: actions/checkout@v2
14+
- name: Login to DockerHub
15+
uses: docker/login-action@v1
16+
with:
17+
username: ${{ secrets.DOCKER_USERNAME }}
18+
password: ${{ secrets.DOCKER_PASSWORD }}
19+
- name: Build and push
20+
id: docker_build
21+
uses: docker/build-push-action@v2
22+
with:
23+
push: true
24+
tags: bencdr/code-server-deploy-container:latest
25+
- name: Image digest
26+
run: echo ${{ steps.docker_build.outputs.digest }}

README.md

+19-52
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,25 @@
1-
# code-server-railway
1+
# deploy-code-server
22

3-
An image built for deploying code-server to [railway.app](https://railway.app).
3+
A collection of one-click buttons and tutorials for deploying code-server to various cloud hosting platforms. The fastest way to get a code-server environment! ☁️
44

5-
To launch your code-server environment, click the button below and log in with GitHub.
6-
7-
[![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)
8-
9-
It will ask you to make a new repo to store this image, so you can add additional software to your repo's `Dockerfile` in the future.
10-
11-
![code-server running inside railway.app](img/code-server-railway.png)
12-
13-
## 💾 Persist your filesystem with `rclone`
14-
15-
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.
16-
17-
You can generate the rclone config on any machine, but it works great on the code-server environment itself, or Google Cloud Shell :)
18-
19-
```sh
20-
# 1. install rclone
21-
# see https://rclone.org/install/ for other install options
22-
$ curl https://rclone.org/install.sh | sudo bash
23-
24-
# 2. create a new rclone remote with your favorite storage provider ☁️
25-
$ rclone config
26-
27-
# 3. Encode your rclone config and copy to your clipboard
28-
$ cat $(rclone config file | sed -n 2p) | base64 --wrap=0 # Linux
29-
$ cat $(rclone config file | sed -n 2p) | base64 --b 0 # MacOS
30-
```
31-
32-
Now, you can add the following the environment variables in the code-server cloud app:
33-
34-
| Environment Variable | Description | Default Value | Required |
35-
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | -------- |
36-
| RCLONE_DATA | the encoded rclone config you copied in step 3 | n/a ||
37-
| RCLONE_REMOTE_NAME | the name of the remote you added in step 2.<br />check with `$ rclone listremotes` | code-server-remote | |
38-
| RCLONE_SOURCE | source directory to sync files in the code-server container | the project directory: `/home/coder/project` | |
39-
| 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 | |
40-
41-
```sh
42-
43-
# How to use:
44-
45-
$ sh /home/coder/push_remote.sh # save your uncomitted files to the remote
46-
47-
$ sh /home/coder/pull_remote.sh # get latest files from the remote
48-
```
5+
| Platform | Type | Cheapest Plan | Deploy |
6+
| ----------------- | ---------------- | ------------------------------------- | ------ |
7+
| DigitalOcean | VM | $5/mo, 1 CPU, 1 GB RAM | Test |
8+
| Vultr | VM | $5/mo, 1 CPU, 1 GB RAM | Test |
9+
| Linode | VM | $3.50/mo, 1 CPU, 512 MB RAM | Test |
10+
| Railway | Deploy Container | Free, specs unknown, but very fast 🚀 | Test |
11+
| Heroku | Deploy Container | Free, 1 CPU, 512 MB RAM | Test |
12+
| Azure App Service | Deploy Container | Free, 1 CPU, 1 GB RAM | Test |
4913

5014
---
5115

52-
## Todo:
16+
## Using a VM vs. Deploying a Container
5317

54-
- [ ] Make `push_remote` and `pull_remote` commands in path
55-
- [ ] Impliment file watcher or auto file sync in VS Code
56-
- [ ] Attach a "push" on a git stash??
57-
- [ ] Add support for SSH / VS Code remote access
58-
- [ ] Make rclone logs visible in environment for debugging
18+
- VMs are deployed once, and then can be modified to install new software
19+
- You need to save "snapshots" to use your latest images
20+
- Storage is always persistent, and you can usually add extra volumes
21+
- VMs can support many workloads, such as running Docker or Kubernetes clusters
22+
- App Platforms deploy code-server containers, and are often rebuilt
23+
- App platforms can shut down when you are not using it, saving you money
24+
- All software and dependencies need to be defined in the `Dockerfile` or install script so they aren't destroyed on a rebuild
25+
- Storage may not be redundant. You may have to use [rclone](https://rclone.org/) to store your filesystem on a cloud service

Dockerfile renamed to deploy-container/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ RUN sudo chown -R coder:coder /home/coder/.local
2525
ENV PORT=8080
2626

2727
# Use our custom entrypoint script first
28-
COPY railway-entrypoint.sh /usr/bin/railway-entrypoint.sh
29-
ENTRYPOINT ["/usr/bin/railway-entrypoint.sh"]
28+
COPY deploy-container-entrypoint.sh /usr/bin/deploy-container-entrypoint.sh
29+
ENTRYPOINT ["/usr/bin/deploy-container-entrypoint.sh"]

deploy-container/README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# code-server-deploy-container
2+
3+
An image built for deploying code-server to [railway.app](https://railway.app), [Heroku](https://heroku.com), or other app engines.
4+
5+
To launch your code-server environment, click the button below and log in with GitHub.
6+
7+
[![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)
8+
9+
For Railway, it will ask you to make a new repo to store this image, so you can add additional software to your repo's `Dockerfile` in the future.
10+
11+
For Heroku, we recommend [using this repo as a template](https://github.com/bpmct/code-server-railway/generate) and using the one-click deploy on your own repo to further modify your app.
12+
13+
![code-server running inside railway.app](img/code-server-railway.png)
14+
15+
## 💾 Persist your filesystem with `rclone`
16+
17+
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.
18+
19+
You can generate the rclone config on any machine, but it works great on the code-server environment itself, or Google Cloud Shell :)
20+
21+
```sh
22+
# 1. install rclone
23+
# see https://rclone.org/install/ for other install options
24+
$ curl https://rclone.org/install.sh | sudo bash
25+
26+
# 2. create a new rclone remote with your favorite storage provider ☁️
27+
$ rclone config
28+
29+
# 3. Encode your rclone config and copy to your clipboard
30+
$ cat $(rclone config file | sed -n 2p) | base64 --wrap=0 # Linux
31+
$ cat $(rclone config file | sed -n 2p) | base64 --b 0 # MacOS
32+
```
33+
34+
Now, you can add the following the environment variables in the code-server cloud app:
35+
36+
| Environment Variable | Description | Default Value | Required |
37+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | -------- |
38+
| RCLONE_DATA | the encoded rclone config you copied in step 3 | n/a ||
39+
| RCLONE_REMOTE_NAME | the name of the remote you added in step 2.<br />check with `$ rclone listremotes` | code-server-remote | |
40+
| RCLONE_SOURCE | source directory to sync files in the code-server container | the project directory: `/home/coder/project` | |
41+
| 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 | |
42+
43+
```sh
44+
45+
# How to use:
46+
47+
$ sh /home/coder/push_remote.sh # save your uncomitted files to the remote
48+
49+
$ sh /home/coder/pull_remote.sh # get latest files from the remote
50+
```
51+
52+
---
53+
54+
## Todo:
55+
56+
- [ ] Make `push_remote` and `pull_remote` commands in path
57+
- [ ] Impliment file watcher or auto file sync in VS Code
58+
- [ ] Attach a "push" on a git stash??
59+
- [ ] Add support for SSH / VS Code remote access
60+
- [ ] Make rclone logs visible in environment for debugging
File renamed without changes.

heroku.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
build:
22
docker:
3-
web: Dockerfile
3+
web: deploy-container/Dockerfile

0 commit comments

Comments
 (0)