FROM python:3.9-slim-buster # Supress TensorFlow & threading logs ENV TF_CPP_MIN_LOG_LEVEL=3 ENV OMP_NUM_THREADS=4 # Set working directory WORKDIR /app # Install PostgreSQL dev libs and build tools RUN apt-get update && apt-get install -y gcc libpq-dev && rm -rf /var/lib/apt/lists/* # Copy and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Copy all project files (including app/, migrations/, aerich.ini, etc) COPY . . # Expose port for Hugging Face Spaces (7860 is default for FastAPI) EXPOSE 7860 # Start: Migrate with Aerich, then launch FastAPI CMD ["sh", "-c", "aerich upgrade && uvicorn app.main:app --host 0.0.0.0 --port 7860"]