FROM python:3.12-slim WORKDIR /app/OpenManus # Install system dependencies including Rust for Python packages RUN apt-get update && apt-get install -y --no-install-recommends \ git \ curl \ wget \ build-essential \ pkg-config \ libssl-dev \ libffi-dev \ sqlite3 \ ca-certificates \ && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ && . $HOME/.cargo/env \ && rm -rf /var/lib/apt/lists/* # Add Rust to PATH ENV PATH="/root/.cargo/bin:${PATH}" # Install uv for faster package management RUN pip install --no-cache-dir uv # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies with Rust support RUN . $HOME/.cargo/env && uv pip install --system -r requirements.txt # Copy application code COPY . . # Create necessary directories and set permissions RUN mkdir -p workspace config assets logs .cache/huggingface \ && chmod -R 755 workspace config assets logs \ && chown -R 1000:1000 workspace config assets logs .cache # Set environment variables for complete deployment ENV PYTHONPATH=/app/OpenManus ENV HF_HOME=/app/OpenManus/.cache/huggingface ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 # Cloudflare environment variables (set by user) ENV CLOUDFLARE_API_TOKEN="" ENV CLOUDFLARE_ACCOUNT_ID="" ENV CLOUDFLARE_WORKER_URL="" ENV CLOUDFLARE_D1_DATABASE_ID="" ENV CLOUDFLARE_R2_BUCKET_NAME="" ENV CLOUDFLARE_KV_NAMESPACE_ID="" # HuggingFace environment variables ENV HF_TOKEN="" ENV HF_API_BASE="https://api-inference.huggingface.co" # Application configuration ENV OPENAI_API_KEY="" ENV ANTHROPIC_API_KEY="" ENV LOG_LEVEL="INFO" # Expose ports EXPOSE 7860 8000 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/ || exit 1 # Create non-root user for security RUN useradd -m -u 1000 openmanus && \ chown -R openmanus:openmanus /app/OpenManus USER openmanus # Default command for complete production deployment CMD ["python", "app_production.py"]