Skip to content

Instantly share code, notes, and snippets.

@stephengfriend
Created June 5, 2019 16:12
Show Gist options
  • Save stephengfriend/a55225709879982a666672b8e4014674 to your computer and use it in GitHub Desktop.
Save stephengfriend/a55225709879982a666672b8e4014674 to your computer and use it in GitHub Desktop.
VS Code as a Service

VS Code as a Service

Getting Started

Pre-requisites

  • Docker
  • Docker Compose
  • Yarn
  • Optional: Docker Machine

Development

  1. Install dependencies
$ yarn install
  1. Launch the service
$ yarn develop
  1. Open browser (http://localhost:8443)

Deployment

  1. Install dependencies
$ yarn install
  1. Create a docker-machine on the desired host
# This example uses Digital Ocean
$ docker-machine create \
    --driver digitalocean \
    --digitalocean-size s-2vcpu-4gb \ # Recommended specs
    --digitalocean-access-token <personal-access-token> # https://cloud.digitalocean.com/account/api/tokens
    vscode
  1. Set your environment to talk to the new machine
$ eval $(docker-machine env vscode)
  1. Make a copy of vscode.env.example and modify, as necessary

  2. Launch the service

$ yarn deploy
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- certs:/etc/nginx/certs
- vhosts:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- vscode
letsencrypt-nginx-proxy-companion:
depends_on:
- nginx-proxy
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes:
- certs:/etc/nginx/certs
- vhosts:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- NGINX_PROXY_CONTAINER=nginx-proxy
networks:
- vscode
vscode:
depends_on:
- nginx-proxy
image: codercom/code-server
container_name: vscode
expose:
- "8443"
env_file:
- vscode.env
entrypoint:
- dumb-init
- code-server
- --allow-http
- --disable-telemetry
networks:
- vscode
networks:
vscode:
volumes:
certs:
vhosts:
html:
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- ./certs:/etc/nginx/certs
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- vscode
vscode:
depends_on:
- nginx-proxy
image: codercom/code-server
container_name: vscode
ports:
- "8443:8443"
entrypoint:
- dumb-init
- code-server
- --allow-http
- --no-auth
- --disable-telemetry
networks:
- vscode
networks:
vscode:
{
"private": true,
"name": "@stephengfriend/vscode",
"version": "1.0.0",
"description": "A turnkey Visual Studio Code environment for the cloud",
"author": "Stephen G. Friend <[email protected]>",
"main": "index.js",
"scripts": {
"deploy": "cross-env COMPOSE_FILE=docker-compose.yml:docker-compose.deploy.yml docker-compose up -d",
"develop": "cross-env COMPOSE_FILE=docker-compose.yml docker-compose up"
},
"license": "MIT",
"devDependencies": {
"cross-env": "^5.2.0"
}
}
PASSWORD=secret
VIRTUAL_HOST=localhost
VIRTUAL_PORT=80
LETSENCRYPT_HOST=localhost
[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment