Experimental
This commit is contained in:
parent
f0fa88a71b
commit
b64082f626
|
@ -0,0 +1,48 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: lint
|
||||
steps:
|
||||
- name: lint
|
||||
image: python:3-slim
|
||||
commands:
|
||||
- echo "Installing lint dependencies..."
|
||||
- pip install --no-cache-dir .[lint] > /dev/null
|
||||
- echo "Running flake8..."
|
||||
- flake8 src
|
||||
- echo "Running pylint..."
|
||||
- pylint src
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: test
|
||||
- name: test
|
||||
image: python:3-slim
|
||||
commands:
|
||||
- echo "Installing test dependencies..."
|
||||
- pip install --no-cache-dir .[test] > /dev/null
|
||||
- echo "Running tests..."
|
||||
- pytest
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build-deploy
|
||||
depends_on:
|
||||
- lint
|
||||
- test
|
||||
steps:
|
||||
- name: build
|
||||
image: python:3-slim
|
||||
commands:
|
||||
- pip install --no-cache-dir build
|
||||
- python -m build --wheel
|
||||
- name: publish
|
||||
image: plugins/pypi
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
settings:
|
||||
username: jackhadrill
|
||||
password:
|
||||
from_secret: password
|
||||
repository: https://git.jacknet.io/api/packages/jackhadrill/pypi
|
||||
skip_build: true
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
// The following will hide Python's build cache directories.
|
||||
"files.exclude": {
|
||||
"**/__pycache__": true,
|
||||
"**/*.egg-info": true,
|
||||
"**/.pytest_cache": true
|
||||
},
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.pylintEnabled": true
|
||||
}
|
44
README.md
44
README.md
|
@ -1,2 +1,44 @@
|
|||
# code-spawner
|
||||
# Code Spawner
|
||||
|
||||
[![Build Status](https://drone.jacknet.io/api/badges/jackhadrill/container-spawner/status.svg)](https://drone.jacknet.io/jackhadrill/container-spawner)
|
||||
|
||||
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:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
services:
|
||||
...
|
||||
container-spawner:
|
||||
image: git.jacknet.io/jackhadrill/container-spawner:latest
|
||||
restart: always
|
||||
environment:
|
||||
CONTAINER_IMAGE: "codercom/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**](https://github.com/oauth2-proxy/oauth2-proxy).
|
||||
|
||||
```bash
|
||||
$ 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`:
|
||||
|
||||
```bash
|
||||
$ export CONTAINER_IMAGE="codercom/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 codercom/code-server:latest
|
||||
```
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "containerspawner"
|
||||
description = "A tool for spawning containers."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
license = {text = "MIT License"}
|
||||
dependencies = []
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
lint = [
|
||||
"pylint>=2.14.5",
|
||||
"flake8>=5.0.4"
|
||||
]
|
||||
test = [
|
||||
"pytest>=7.1.2"
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# N.B. This is here for legacy support in order to support editable installs. Please see:
|
||||
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#pep660-status
|
||||
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setupcfg-caveats
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
setup()
|
|
@ -0,0 +1,2 @@
|
|||
def test_main():
|
||||
assert True
|
Loading…
Reference in New Issue