begin refactor

This commit is contained in:
Ben
2021-03-04 03:27:07 -05:00
parent 10bca025d0
commit df02690a07
7 changed files with 108 additions and 55 deletions

26
.github/workfows/to-docker-hub.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Publish to Docker Hub
on:
push:
branches:
- main
workflow_dispatch:
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: bencdr/code-server-deploy-container:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@@ -1,58 +1,25 @@
# code-server-railway
# deploy-code-server
An image built for deploying code-server to [railway.app](https://railway.app).
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! ☁️
To launch your code-server environment, click the button below and log in with GitHub.
[![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)
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.
![code-server running inside railway.app](img/code-server-railway.png)
## 💾 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.
You can generate the rclone config on any machine, but it works great on the code-server environment itself, or Google Cloud Shell :)
```sh
# 1. install rclone
# see https://rclone.org/install/ for other install options
$ curl https://rclone.org/install.sh | sudo bash
# 2. create a new rclone remote with your favorite storage provider ☁️
$ rclone config
# 3. Encode your rclone config and copy to your clipboard
$ cat $(rclone config file | sed -n 2p) | base64 --wrap=0 # Linux
$ cat $(rclone config file | sed -n 2p) | base64 --b 0 # MacOS
```
Now, you can add the following the environment variables in the code-server cloud app:
| 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.<br />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 | |
```sh
# How to use:
$ 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
```
| 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 |
| Railway | Deploy Container | Free, specs unknown, but very fast 🚀 | Test |
| Heroku | Deploy Container | Free, 1 CPU, 512 MB RAM | Test |
| Azure App Service | Deploy Container | Free, 1 CPU, 1 GB RAM | Test |
---
## Todo:
## Using a VM vs. Deploying a Container
- [ ] 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
- VMs are deployed once, and then can be modified to install new software
- You need to save "snapshots" to use your latest images
- Storage is always persistent, and you can usually add extra volumes
- VMs can support many workloads, such as running Docker or Kubernetes clusters
- App Platforms deploy code-server containers, and are often rebuilt
- App platforms can shut down when you are not using it, saving you money
- All software and dependencies need to be defined in the `Dockerfile` or install script so they aren't destroyed on a rebuild
- Storage may not be redundant. You may have to use [rclone](https://rclone.org/) to store your filesystem on a cloud service

View File

@@ -25,5 +25,5 @@ RUN sudo chown -R coder:coder /home/coder/.local
ENV PORT=8080
# Use our custom entrypoint script first
COPY railway-entrypoint.sh /usr/bin/railway-entrypoint.sh
ENTRYPOINT ["/usr/bin/railway-entrypoint.sh"]
COPY deploy-container-entrypoint.sh /usr/bin/deploy-container-entrypoint.sh
ENTRYPOINT ["/usr/bin/deploy-container-entrypoint.sh"]

View File

@@ -0,0 +1,60 @@
# code-server-deploy-container
An image built for deploying code-server to [railway.app](https://railway.app), [Heroku](https://heroku.com), or other app engines.
To launch your code-server environment, click the button below and log in with GitHub.
[![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)
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.
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.
![code-server running inside railway.app](img/code-server-railway.png)
## 💾 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.
You can generate the rclone config on any machine, but it works great on the code-server environment itself, or Google Cloud Shell :)
```sh
# 1. install rclone
# see https://rclone.org/install/ for other install options
$ curl https://rclone.org/install.sh | sudo bash
# 2. create a new rclone remote with your favorite storage provider ☁️
$ rclone config
# 3. Encode your rclone config and copy to your clipboard
$ cat $(rclone config file | sed -n 2p) | base64 --wrap=0 # Linux
$ cat $(rclone config file | sed -n 2p) | base64 --b 0 # MacOS
```
Now, you can add the following the environment variables in the code-server cloud app:
| 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.<br />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 | |
```sh
# How to use:
$ 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
```
---
## 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

View File

@@ -1,3 +1,3 @@
build:
docker:
web: Dockerfile
web: deploy-container/Dockerfile