File size: 1,158 Bytes
23654e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b55f151
 
 
23654e5
d6a961e
 
 
23654e5
 
 
 
 
 
 
b55f151
d6a961e
 
 
23654e5
 
 
 
 
 
 
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
# Hugging Face Spaces Dockerfile
FROM python:3.11-slim

# Set working directory
WORKDIR /app

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

# Copy requirements
COPY requirements.txt .

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

# Copy application code
COPY . .

# Create data directory in a writable location for HF Spaces
# HF Spaces has persistent storage at /data
RUN mkdir -p /data && chmod 777 /data

# Create cache directory for Hugging Face models
RUN mkdir -p /data/.cache/huggingface && chmod -R 777 /data/.cache

# Hugging Face Spaces uses port 7860
EXPOSE 7860

# Set environment variables
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
ENV DATABASE_PATH=/data/app.db
ENV HF_HOME=/data/.cache/huggingface
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface
ENV HUGGINGFACE_HUB_CACHE=/data/.cache/huggingface

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
  CMD curl -f http://localhost:7860/login || exit 1

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