Deploy Kubiya agents using Docker containers
This guide covers deploying Kubiya agents using Docker containers.
FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . EXPOSE 8000 CMD ["python", "server.py"]
version: '3.8' services: kubiya-agent: build: . ports: - "8000:8000" environment: - KUBIYA_API_KEY=${KUBIYA_API_KEY} - KUBIYA_ENVIRONMENT=production volumes: - ./logs:/app/logs restart: unless-stopped redis: image: redis:7-alpine ports: - "6379:6379" volumes: - redis_data:/data restart: unless-stopped volumes: redis_data:
# Required KUBIYA_API_KEY=your_api_key_here KUBIYA_ENVIRONMENT=production # Optional KUBIYA_LOG_LEVEL=INFO KUBIYA_PORT=8000 KUBIYA_HOST=0.0.0.0 REDIS_URL=redis://redis:6379
# Build stage FROM python:3.11-slim as builder WORKDIR /app COPY requirements.txt . RUN pip install --user -r requirements.txt # Runtime stage FROM python:3.11-slim WORKDIR /app # Copy installed packages COPY --from=builder /root/.local /root/.local ENV PATH=/root/.local/bin:$PATH COPY . . EXPOSE 8000 CMD ["python", "server.py"]
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1
# Create non-root user RUN adduser --disabled-password --gecos '' appuser USER appuser # Set security options LABEL security.privilege="unprivileged"
services: kubiya-agent: deploy: resources: limits: cpus: '2' memory: 4G reservations: cpus: '1' memory: 2G
# Build image docker build -t kubiya-agent:latest . # Tag for registry docker tag kubiya-agent:latest your-registry.com/kubiya-agent:latest # Push to registry docker push your-registry.com/kubiya-agent:latest
# View logs docker logs kubiya-agent # Follow logs docker logs -f kubiya-agent # With timestamps docker logs -t kubiya-agent
# Real-time stats docker stats kubiya-agent # Resource usage docker exec kubiya-agent ps aux
Was this page helpful?