# Use official Python base image FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends gcc python3-venv && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Create and activate virtual environment ENV VIRTUAL_ENV=/opt/venv RUN python -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Upgrade pip and essential tools RUN pip install --no-cache-dir --upgrade pip setuptools wheel # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies in venv RUN pip install --no-cache-dir -r requirements.txt # Copy the source code COPY . . # Clean any previous installations and install the package RUN pip uninstall -y simpleguardhome || true && \ pip install -e . && \ pip show simpleguardhome && \ python3 -c "import simpleguardhome; print('Package found at:', simpleguardhome.__file__)" # Copy and set up entrypoint script COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh # Create rules backup directory with proper permissions RUN mkdir -p /app/rules_backup && \ chmod 777 /app/rules_backup # Default environment variables ENV ADGUARD_HOST="http://localhost" \ ADGUARD_PORT=3000 # Expose the application port EXPOSE 8000 # Volume for persisting rules backups VOLUME ["/app/rules_backup"] # Set entrypoint ENTRYPOINT ["docker-entrypoint.sh"]