Go to file
Jack Hadrill 44cf0564e9
continuous-integration/drone/push Build is passing Details
Merge pull request 'feature/disable-restart' (#2) from feature/disable-restart into main
Reviewed-on: #2
2022-08-27 20:12:57 +00:00
.vscode Experimental 2022-08-24 23:56:49 +00:00
src/containerspawner Update 'src/containerspawner/state.py' 2022-08-27 20:07:09 +00:00
test Experimental 2022-08-24 23:56:49 +00:00
.drone.yml Update '.drone.yml' 2022-08-27 20:00:43 +00:00
.flake8 Experimental 2022-08-24 23:56:49 +00:00
.gitignore Initial commit 2022-08-24 21:41:05 +00:00
.pylintrc Experimental 2022-08-24 23:56:49 +00:00
Dockerfile First working version. 2022-08-27 18:31:48 +00:00
LICENSE Initial commit 2022-08-24 21:41:05 +00:00
README.md Update README and supported HTTP methods. 2022-08-27 18:45:09 +00:00
pyproject.toml First working version. 2022-08-27 18:31:48 +00:00
setup.cfg Update 'setup.cfg' 2022-08-27 20:11:21 +00:00
setup.py Experimental 2022-08-24 23:56:49 +00:00

README.md

Code Spawner

Build Status

A tool for spawning a bespoke container upon receiving an HTTP request.

Usage

More details coming soon.

An example docker-compose.yml config is show below:

version: '3'
services:
  ...
  container-spawner:
    image: git.jacknet.io/jackhadrill/container-spawner:latest
    restart: always
    environment:
      CONTAINER_IMAGE: "git.jacknet.io/jackhadrill/code-server:latest"
      CONTAINER_PREFIX: "vscode"
      CONTAINER_NETWORK: "vscode_backend"
      CONTAINER_PERSIST: "/home/coder"
  ...

Process description

Upon receiving any HTTP request, Code Spawner will launch a bespoke container on behalf of the user (if not already existing), equivalent to having used the command below. The user's name is derived from the X-Forwarded-Preferred-User header, original sent by OAuth2 Proxy.

$ docker run -d --rm --name ${CONTAINER_PREFIX}-${X-Forwarded-Preferred-User} -v ${CONTAINER_PREFIX}-${X-Forwarded-Preferred-User}:${CONTAINER_PERSIST} --network ${CONTAINER_NETWORK} ${IMAGE_NAME}

For example, assuming X-Forwarded-Preferred-User is jack:

$ export CONTAINER_IMAGE="git.jacknet.io/jackhadrill/code-server:latest"
$ export CONTAINER_PREFIX="vscode"
$ export CONTAINER_NETWORK="vscode_backend"
$ export CONTAINER_PERSIST="/home/coder"
$ docker run -d --rm --name vscode-jack -v vscode-jack:/home/coder --network vscode_backend git.jacknet.io/jackhadrill/code-server:latest