# Use an official Python runtime as a parent image FROM python:3.10 # Set the working directory in the container WORKDIR /code # Set the home directory for Hugging Face cache to a writable location ENV HF_HOME="/data/huggingface-cache" # 1. Copy and install requirements first to leverage Docker layer caching COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # 2. Copy the rest of your application code COPY . /code/ # 3. Create directories and set correct permissions # This ensures the app has permission to write to the cache and ChromaDB folders RUN mkdir -p /data/chroma_db /data/huggingface-cache && \ chown -R 1000:1000 /code /data # 4. Run the one-time setup script to populate the database # REMEMBER to remove this line after the first successful deployment # Switch to a non-root user for better security USER 1000 # 5. Run the application # Note: We are using 'app:app' which assumes your main file is named 'app.py' CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]