# Docker Container Updates for Integration Support

This document outlines the updates made to support Python and Node.js/Node-RED integrations in the Qrusty Docker containers.

## Changes Made

### 1. Development Container (`.devcontainer/Dockerfile`)

**Added Dependencies:**

- Python 3 runtime and pip package manager
- Python virtual environment support (`python3-venv`)
- Node.js LTS via NodeSource repository
- Node-RED global installation
- Qrusty Python integration dependencies from `requirements.txt`

**Key Additions:**

```dockerfile
# Install Python and Node.js
RUN apt-get update && apt-get install -y \
    python3 \
    python3-pip \
    python3-venv \
    curl \
    && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
    && apt-get install -y nodejs

# Install Python dependencies for Qrusty integrations
COPY integrations/python/requirements.txt /tmp/requirements.txt
RUN pip3 install --break-system-packages -r /tmp/requirements.txt

# Install Node-RED for development
RUN npm install -g node-red
```

### 2. Production Container (`Dockerfile`)

**Builder Stage Updates:**

- Added Python 3 and pip for build-time validation
- Added Node.js for build-time integration testing

**Runtime Stage Updates:**

- Python 3 runtime for Python integration clients
- Node.js runtime for Node-RED integration support
- Pre-installed Python dependencies from `requirements.txt`
- Integration examples copied to `/opt/qrusty/integrations`

**Key Runtime Additions:**

```dockerfile
# Install runtime dependencies for integrations
RUN apt-get update && apt-get install -y \
    python3 \
    python3-pip \
    curl \
    ca-certificates \
    && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
    && apt-get install -y nodejs

# Install Python dependencies and copy examples
COPY --from=builder /workspace/integrations/python/requirements.txt /tmp/requirements.txt
RUN pip3 install --break-system-packages -r /tmp/requirements.txt
COPY --from=builder /workspace/integrations /opt/qrusty/integrations
```

### 3. Dev Container Configuration (`.devcontainer/devcontainer.json`)

**Added Extensions:**

- `ms-python.python` - Python language support
- `ms-python.flake8` - Python linting
- `ms-python.pylint` - Python code analysis
- `ms-vscode.vscode-json` - Enhanced JSON support for Node.js/Node-RED
- `ms-vscode.vscode-typescript-next` - TypeScript/JavaScript support

**Added Port Forwarding:**

- `6784` - Qrusty server default port
- `1880` - Node-RED default port

**Updated Post-Create Command:**

```jsonc
"postCreateCommand": "rustc --version && cargo --version && python3 --version && node --version && npm --version"
```

## Integration Support

### Python Integration

- **Runtime:** Python 3.12+
- **Package Manager:** pip3
- **Dependencies:** `requests==2.32.5` (from requirements.txt)
- **Usage:** Client libraries can use `requests` to interact with Qrusty HTTP API
- **Location:** Integration examples available at `/opt/qrusty/integrations/python/`

### Node-RED Integration

- **Runtime:** Node.js LTS
- **Package Manager:** npm
- **Node-RED:** Globally available in development container
- **Usage:** Custom Node-RED nodes for Qrusty queue operations
- **Location:** Integration examples available at `/opt/qrusty/integrations/node-red/`

## Validation

A validation script is available at `scripts/validate_dependencies.sh` that checks:

- Rust toolchain availability
- Python runtime and package manager
- Node.js runtime and npm
- Integration example files
- Installed Python packages

**Run validation:**

```bash
./scripts/validate_dependencies.sh
```

## Container Sizes

These updates will increase container size due to added runtimes:

- **Python 3:** ~50-100MB
- **Node.js LTS:** ~150-200MB
- **Node-RED:** ~50-100MB (dev container only)

The production container includes only essential runtime components, while the development container includes full development tools.

## Usage Examples

### Python Client Example

```bash
# Inside container
cd /opt/qrusty/integrations/python
python3 qrusty_publish.py
```

### Node-RED Development

```bash
# Inside dev container
node-red
# Access Node-RED at http://localhost:1880
```

### Testing Integration Examples

```bash
# Validate all examples work
make examples
```

This ensures that both development and production environments have all necessary dependencies for the complete Qrusty ecosystem including Python and Node-RED integrations.
