snake_api / Dockerfile
humza7656's picture
Upload 4 files
e966654 verified
raw
history blame contribute delete
935 Bytes
# Use a Python base image
FROM python:3.10-slim
# Set the working directory
WORKDIR /app
# Copy the requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# --- IMPORTANT: Configure Caching to /tmp ---
# Spaces only allow writing to /tmp, which is critical for many ML libraries.
# Although not strictly required for google-genai, it is a best practice.
ENV XDG_CACHE_HOME=/tmp/hf_cache
ENV HF_HOME=/tmp/hf_cache
# Copy your application code
# This copies main.py, snake_rec.py, and your .env (if you want to use it
# but using HF Secrets is much better, see Step 3)
COPY . .
# Expose the required port (7860 is the default for HF Spaces)
EXPOSE 7860
# The command to run your FastAPI application using uvicorn
# 'main:app' refers to the 'app' object in 'main.py'
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]