File size: 874 Bytes
7b41846
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim

WORKDIR /code

# Install system dependencies
RUN apt-get update && apt-get install -y \

    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Set up HuggingFace cache directory
RUN mkdir -p /code/.cache/huggingface && chmod -R 777 /code/.cache/huggingface
ENV HF_HOME /code/.cache/huggingface

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

# Copy application code
COPY . .

# Expose the port that Hugging Face Spaces expects
EXPOSE 7860

# Set environment variables
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1
# Add Space-specific environment variables
ENV HOST=0.0.0.0
ENV PORT=7860

# Run the application with the correct host and port for Spaces
CMD ["python", "-c", "from app import app; app.run(host='0.0.0.0', port=7860)"]