Spaces:
Running
Running
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)"] |