FROM python:3.11-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Create a non-root user RUN useradd --create-home --shell /bin/bash myuser # Set the working directory in the container WORKDIR /usr/src/swarms # Change ownership of the workspace directory to the new user RUN mkdir -p /usr/src/swarms/agent_workspace && \ chown -R myuser:myuser /usr/src/swarms/agent_workspace # Switch to the non-root user USER myuser # Copy the requirements file and pyproject.toml to the container COPY pyproject.toml requirements.txt ./ # Install Python dependencies RUN pip install --upgrade pip RUN pip install --no-cache-dir -r requirements.txt # Install additional dependencies, including swarm-models RUN pip install fastapi uvicorn pydantic loguru python-dotenv swarm-models # Copy the rest of the application files from the root COPY . . # Verify installations RUN python --version RUN pip show fastapi uvicorn pydantic loguru python-dotenv swarm-models # Expose port for FastAPI EXPOSE 8000 # Command to run the FastAPI app using Uvicorn CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]