# Use the official Miniconda image to support your environment.yaml FROM continuumio/miniconda3 # 1. HUGGING FACE SECURITY REQUIREMENT # Spaces run as a non-root user. We must create a user with UID 1000. RUN useradd -m -u 1000 user USER user # Set up the home directory paths for the new user ENV HOME=/home/user \ PATH=/home/user/.conda/envs/agent-store-api/bin:$PATH WORKDIR $HOME/app # 2. ENVIRONMENT SETUP # Copy the Conda config first, ensuring our non-root user owns the file COPY --chown=user environment.yaml . # Build the Conda environment inside the container RUN conda env create -f environment.yaml # 3. APPLICATION CODE # Copy your app folder, db folder, and configurations COPY --chown=user . . # 4. HUGGING FACE PORT REQUIREMENT # Spaces strictly routes external traffic to port 7860 EXPOSE 7860 # 5. EXECUTION # Run Uvicorn through Conda, pointing to the app module, mapped to 0.0.0.0:7860 CMD ["conda", "run", "--no-capture-output", "-n", "agent-store-api", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]