feat: merge opus comfyui and login updates

This commit is contained in:
boos
2026-05-21 16:32:04 +02:00
parent c16479da7c
commit 9c84759498
105 changed files with 20160 additions and 1034 deletions
@@ -0,0 +1,34 @@
## ADDED Requirements
### Requirement: Backend-agnostic ContainerRuntime trait
The system SHALL expose container lifecycle behind a single `ContainerRuntime` trait so the pool, proxy, and route handlers do NOT depend on Docker directly.
#### Scenario: Pool uses only the trait
- **WHEN** the source for `services/comfyui_pool.rs` is inspected
- **THEN** it imports `ContainerRuntime` and `ContainerSpec` only — never `bollard`, `docker`, or `kube` types
#### Scenario: Trait surface is sufficient for v1
- **WHEN** a `DockerRuntime` is provided
- **THEN** the pool can start containers, stop them, check liveness, and list existing `comfyui-user-*` containers using only the trait's methods
### Requirement: DockerRuntime implementation
The system SHALL ship a `DockerRuntime` that implements `ContainerRuntime` against the local Docker daemon, either via the host socket `/var/run/docker.sock` or the `docker` CLI.
#### Scenario: Start spawns a container
- **WHEN** `DockerRuntime::start(spec)` is called with `image=bosapi-comfyui:multi-tenant`, `name=comfyui-user-7`, port mapping, env, and volume mounts
- **THEN** a container with that name exists, is running, and exposes the chosen host port
#### Scenario: Stop removes the container
- **WHEN** `DockerRuntime::stop("comfyui-user-7")` is called
- **THEN** the container is stopped and removed (image used `--rm`-equivalent semantics) and its name becomes reusable
#### Scenario: List finds existing user containers
- **WHEN** `DockerRuntime::list_user_containers()` is called
- **THEN** it returns one entry per running container whose name starts with `comfyui-user-`, including its port mapping
### Requirement: K3S extension point reserved
The trait SHALL be designed such that a future `K3sRuntime` implementing the same surface can replace `DockerRuntime` without changes to the pool, proxy, or route handlers.
#### Scenario: Swapping runtimes does not break callers
- **WHEN** `AppState::comfyui_pool` is constructed with a `Box<dyn ContainerRuntime>` instead of a concrete `DockerRuntime`
- **THEN** all callers compile and behavior is unchanged for the `DockerRuntime` instance