containerspawner (0.1.1.post1)

Published 2022-08-27 21:14:13 +01:00 by jackhadrill in jackhadrill/container-spawner

Installation

pip install --index-url  containerspawner

About this package

A tool for spawning containers.

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

Requirements

Requires Python: >=3.9
Details
PyPI
2022-08-27 21:14:13 +01:00
38
MIT License
5.1 KiB
Assets (1)
Versions (3) View all
0.1.1.post1 2022-08-27
0.1.1 2022-08-27
0.1.0 2022-08-27