File size: 2,078 Bytes
d94d354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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"]