FROM python:3.9-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy gateway files
COPY gateway.py config.yaml ./

# Create non-root user
RUN useradd -m -u 1000 gateway
USER gateway

# Run gateway
CMD ["python", "-u", "gateway.py"]