"""
Docker template strings for DNR containers.

Contains Dockerfile templates and docker-compose templates for split container mode.
The actual container runtime code is in dazzle_ui.runtime.container package.
"""

from __future__ import annotations

# =============================================================================
# Split Container Templates
# =============================================================================

DAZZLE_BACKEND_DOCKERFILE = """# Runtime Backend Container
# Generated by Dazzle Runtime
FROM python:3.11-slim

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \\
    gcc curl && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir \\
    fastapi uvicorn[standard] aiosqlite pydantic

# Copy specs
COPY backend_spec.json ./
COPY ui_spec.json ./

# Copy container runtime package
COPY container/ ./container/

RUN mkdir -p /app/.dazzle

EXPOSE {api_port}

ENV PYTHONUNBUFFERED=1
ENV DAZZLE_HOST=0.0.0.0
ENV DAZZLE_API_PORT={api_port}
ENV DAZZLE_DB_PATH=/app/.dazzle/data.db

HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=3 \\
    CMD curl -f http://localhost:{api_port}/health || exit 1

CMD ["python", "-m", "container"]
"""

DAZZLE_SINGLE_COMPOSE_TEMPLATE = """# Runtime Docker Compose - Single Container
# Generated by Dazzle Runtime
name: {project_name}

services:
  app:
    build:
      context: ./backend
    container_name: {container_name}
    ports:
      - "{frontend_port}:{api_port}"
      - "{api_port}:{api_port}"
    volumes:
      - {volume_name}:/app/.dazzle
    environment:
      - DAZZLE_TEST_MODE={test_mode}
      - DAZZLE_DEV_MODE={dev_mode}
      - DAZZLE_API_PORT={api_port}
      - DAZZLE_AUTH_ENABLED={auth_enabled}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:{api_port}/health"]
      interval: 5s
      timeout: 10s
      retries: 5
      start_period: 15s

volumes:
  {volume_name}:
"""


# =============================================================================
# .dockerignore Template
# =============================================================================

DAZZLE_DOCKERIGNORE = """# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
venv/
env/
ENV/
.venv

# Build
build/
dist/
*.egg-info/

# Testing
.pytest_cache/
.coverage
htmlcov/
.hypothesis/

# IDE
.vscode/
.idea/
*.swp
*.swo

# Git
.git/
.gitignore

# Dazzle artifacts (keep dsl/ and dazzle.toml)
.dazzle/

# Misc
.DS_Store
*.log
.env
.env.*
!.env.example
"""
