# Base image FROM python:3.12 # Install Nginx and sudo (needed for Hugging Face Spaces) RUN apt-get update && apt-get install -y nginx sudo # Create non-root user RUN useradd -m -u 1000 user && \ echo "user ALL=(root) NOPASSWD: /usr/sbin/nginx" >> /etc/sudoers # Set working directory WORKDIR /app # Clone GitHub repo RUN git clone https://github.com/Mekhlafi98/solverai.git -b develop2 /app # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip gunicorn && \ pip install --no-cache-dir -r requirements.txt # Set environment variables ENV PATH="/home/user/.local/bin:$PATH" \ OCR_API_TOKEN=${OCR_API_TOKEN} \ GOOGLE_API_KEY=${GOOGLE_API_KEY} \ TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} \ MODEL_NAME=gemini-1.5-flash \ ALLOWED_HOSTS=localhost,127.0.0.1,azeez98-solveai.hf.space # Collect static files RUN python manage.py collectstatic --noinput # Copy NGINX config (modified for Hugging Face) COPY nginx/default.conf /etc/nginx/conf.d/default.conf # Create necessary directories RUN mkdir -p /var/lib/nginx/body /var/log/nginx /app/static /app/media && \ chown -R user:user /var/lib/nginx /var/log/nginx /app # Copy start script COPY start.sh /start.sh RUN chmod +x /start.sh # Use port 8080 instead of 80 for Hugging Face EXPOSE 8080 # Run as non-root user by default USER user # Start command for Hugging Face CMD ["/bin/bash", "/start.sh"]