Skip to content

[v2.1] Docker Agent - Template System Integration #153

Description

@JoshuaAFerguson

Epic: v2.1 Docker Agent Development
Component: Docker Agent - Template System
Assignee: Builder (Agent 2)
Milestone: v2.1
Estimated Effort: 8-12 hours

Overview

Enable Docker Agent to parse templates and create Docker containers from StreamSpace templates.

Requirements

Template Parsing

  • Fetch templates from Control Plane API
  • Parse template manifest (YAML/JSON)
  • Convert template to Docker container configuration
  • Support template variables and substitution
  • Cache templates locally

Template Structure

Reuse existing template format from K8s agent:

apiVersion: streamspace.io/v1alpha1
kind: Template
metadata:
  name: firefox-browser
spec:
  displayName: "Firefox Browser"
  description: "Mozilla Firefox web browser"
  image: linuxserver/firefox:latest
  vnc:
    enabled: true
    port: 3000
  resources:
    memory: 512Mi
    cpu: 250m
  env:
    - name: DISPLAY
      value: ":1"
  volumes:
    - name: home
      mountPath: /config
      persistent: true

Docker Conversion

Template → Docker Container:

// Parse template
template := parseTemplate(templateYAML)

// Convert to Docker config
containerConfig := &container.Config{
    Image: template.Spec.Image,
    Env: convertEnvVars(template.Spec.Env),
    ExposedPorts: convertPorts(template.Spec.VNC),
}

hostConfig := &container.HostConfig{
    Resources: container.Resources{
        Memory: convertMemory(template.Spec.Resources.Memory),
        NanoCPUs: convertCPU(template.Spec.Resources.CPU),
    },
    Binds: convertVolumes(template.Spec.Volumes, sessionID),
}

Resource Mapping

Template Docker
resources.memory: 512Mi Resources.Memory: 536870912 (bytes)
resources.cpu: 250m Resources.NanoCPUs: 250000000
volumes Docker volumes or bind mounts
env Container environment variables

Files to Create/Update

agents/docker-agent/
└── pkg/
    └── docker/
        ├── template.go       # Template parsing
        ├── converter.go      # Template → Docker config
        └── resources.go      # Resource conversion

Testing Checklist

  • Parse K8s-style templates successfully
  • Convert templates to Docker config correctly
  • Memory limits applied correctly
  • CPU limits applied correctly
  • Environment variables passed to container
  • VNC port configuration correct
  • Volumes created and mounted
  • Multiple templates supported
  • Template caching works
  • Invalid templates handled gracefully

Template Examples to Support

  1. firefox-browser - GUI browser with VNC
  2. vscode - VS Code IDE with VNC
  3. ubuntu-desktop - Full Ubuntu desktop
  4. chrome - Chromium browser

Success Criteria

  • ✅ All existing K8s templates work with Docker agent
  • ✅ Resource limits enforced correctly
  • ✅ VNC port configuration correct
  • ✅ Persistent volumes work
  • ✅ Template validation prevents invalid configs

Depends On: #151 (Docker Agent Core Implementation)
Related: K8s Agent template handling (reference implementation)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions