# Use Python 3.9 as the base image
FROM python:3.11-slim


# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    python3-dev \
    libvirt-dev \
    net-tools \
    dmidecode \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    docker.io \
    openvswitch-switch \
    pciutils \
    qemu-utils

# Create and set working directory
WORKDIR /app

# Copy requirements first to leverage Docker cache
COPY requirements.txt .

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

# Copy the rest of the application
COPY . /app

# Set environment variables (can be overridden in docker-compose)
ENV PYTHONUNBUFFERED=1
ENV DOCKER_HOST=unix:///var/run/docker.sock

# Create a group and user to run the app
#RUN groupadd -r worker && useradd -r -g worker worker \
#    && chown -R worker:worker /app
#USER worker
USER root
# Entrypoint command
CMD ["python", "main.py"]