File size: 1,131 Bytes
66fef64
 
 
 
 
 
b1c879a
66fef64
 
 
 
 
 
 
 
 
 
 
 
 
 
2f58804
7bec29d
2f58804
 
 
 
 
 
 
66fef64
b1c879a
 
 
66fef64
 
 
b1c879a
 
66fef64
 
b1c879a
 
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
FROM python:3.9-slim

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

# Set working directory
WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .

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

# Copy application code
COPY app/ ./app/

# Create data directory and cache directories with proper permissions
RUN mkdir -p app/data && chmod 777 app/data
RUN mkdir -p /tmp/hf_cache && chmod 777 /tmp/hf_cache
RUN mkdir -p /app/.cache && chmod 777 /app/.cache

# Set environment variables for HF cache
ENV HF_HOME=/tmp/hf_cache
ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache
ENV TRANSFORMERS_CACHE=/tmp/hf_cache

# Make start script executable
RUN chmod +x app/start.py

# Expose port
EXPOSE 7860

# Health check with longer timeout for initial build
HEALTHCHECK --interval=30s --timeout=30s --start-period=300s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Run the startup script that builds index if needed, then starts the API
CMD ["python", "app/start.py"]