ln-731-docker-generator

L3 Worker - Generates Docker and docker-compose configuration

Main Workflow (4 Phases)

stateDiagram-v2 [*] --> Validate: Receive Config from ln-730 state Validate { [*] --> CheckStack CheckStack --> CheckVersions: Stack OK CheckVersions --> CheckDir: Versions OK CheckDir --> [*]: Ready CheckStack --> Error: Invalid Stack } Validate --> Select: Validated Validate --> [*]: Error state Select { [*] --> StackType StackType --> FrontendTemplates: Has Frontend StackType --> BackendTemplates: Has Backend FrontendTemplates --> BackendTemplates BackendTemplates --> [*] } Select --> Substitute: Templates Selected state Substitute { [*] --> ReplaceVars ReplaceVars --> NodeVersion NodeVersion --> DotNetVersion DotNetVersion --> PythonVersion PythonVersion --> [*] } Substitute --> Generate: Variables Applied state Generate { [*] --> CheckExisting CheckExisting --> WriteFiles: No Conflicts CheckExisting --> WarnOverwrite: Files Exist WarnOverwrite --> WriteFiles WriteFiles --> [*] } Generate --> [*]: Files Created

Template Selection Logic

flowchart TB Input([Stack Config]) --> HasFrontend{Has Frontend?} HasFrontend -->|Yes| Frontend[Select dockerfile_frontend.template] HasFrontend -->|No| SkipFrontend[Skip Frontend] Frontend --> HasBackend{Backend Type?} SkipFrontend --> HasBackend HasBackend -->|.NET| DotNet[Select dockerfile_backend_dotnet.template] HasBackend -->|Python| Python[Select dockerfile_backend_python.template] HasBackend -->|None| SkipBackend[Skip Backend] DotNet --> Compose[Select docker_compose.template] Python --> Compose SkipBackend --> Compose Compose --> Ignore[Select dockerignore.template] Ignore --> HasFrontendNginx{Has Frontend?} HasFrontendNginx -->|Yes| Nginx[Select nginx.template] HasFrontendNginx -->|No| Output([Templates Selected]) Nginx --> Output classDef template fill:#C8E6C9 classDef decision fill:#E3F2FD class Frontend,DotNet,Python,Compose,Ignore,Nginx template class HasFrontend,HasBackend,HasFrontendNginx decision

Generated File Structure

flowchart LR subgraph Project["Project Root"] DC[docker-compose.yml] DI[.dockerignore] DB[Dockerfile.backend] subgraph Frontend["src/frontend/"] DF[Dockerfile] NG[nginx.conf] end end DC -->|references| DB DC -->|references| DF DF -->|uses| NG classDef file fill:#FFF9C4 classDef config fill:#E3F2FD class DC,DI,DB,DF config class NG file

Multi-stage Build Flow

flowchart TB subgraph Frontend["Frontend Dockerfile"] F1[Stage 1: node:alpine] F1 -->|npm ci| F2[Install deps] F2 -->|npm build| F3[Build assets] F3 --> F4[Stage 2: nginx:alpine] F4 -->|COPY dist| F5[Production Image] end subgraph Backend["Backend Dockerfile (.NET)"] B1[Stage 1: dotnet/sdk] B1 -->|restore| B2[Restore deps] B2 -->|publish| B3[Build release] B3 --> B4[Stage 2: dotnet/aspnet] B4 -->|COPY app| B5[Production Image] end F5 --> Size1([~50MB]) B5 --> Size2([~200MB]) classDef stage fill:#E3F2FD classDef result fill:#C8E6C9 class F1,F4,B1,B4 stage class F5,B5,Size1,Size2 result