File size: 1,407 Bytes
72f6109
fa84e12
72f6109
70115d2
 
1ec4aec
72f6109
70115d2
 
72f6109
 
 
 
70115d2
5292f5e
72f6109
d162128
 
 
 
 
0bba6a6
 
582d2a3
 
779e32a
582d2a3
72f6109
39ed0cf
72f6109
 
70115d2
00fe528
72f6109
70115d2
3047107
 
0bba6a6
70115d2
00fe528
70115d2
00fe528
70115d2
 
d162128
70115d2
 
1ec4aec
70115d2
698ec96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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"]