FROM python:3.11-slim

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

# Install Python dependencies
RUN pip install --no-cache-dir \
    requests \
    watchdog

# Create app directory
WORKDIR /app

# Copy the Python script
COPY main.py .

# Make the script executable
RUN chmod +x main.py

# Create a non-root user
RUN useradd -m -u 1000 appuser && \
    chown -R appuser:appuser /app

# Switch to non-root user
USER appuser

# Set default environment variables
ENV PORT_FORWARDED=/tmp/port_forwarded
ENV HTTP_S=http

# Run the application
CMD ["python", "main.py"]