File size: 1,216 Bytes
7644eac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a08ee99
 
 
 
7644eac
 
 
 
 
 
 
 
a08ee99
7644eac
a08ee99
 
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
51
52
# Hugging Face Spaces Dockerfile
# Reference: https://huggingface.co/docs/hub/spaces-sdks-docker

FROM python:3.11-slim

# Set working directory
WORKDIR /app

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

# Create a non-root user (required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set working directory for user
WORKDIR $HOME/app

# Copy requirements first for caching
COPY --chown=user requirements.txt .

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

# Copy application code
COPY --chown=user . .

# Create necessary directories with proper permissions
RUN mkdir -p vector_db cache learning_paths instance

# Make startup script executable
RUN chmod +x start.sh

# Hugging Face Spaces requires port 7860
EXPOSE 7860

# Set environment variables for Hugging Face
ENV PORT=7860
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=web_app:create_app

# Run the startup script (initializes DB then starts gunicorn)
CMD ["bash", "start.sh"]