-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
144 lines (116 loc) · 5.9 KB
/
Copy pathDockerfile
File metadata and controls
144 lines (116 loc) · 5.9 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# OpenClaw Multi-Agent System Dockerfile
# Production deployment image for Railway with 6 specialized agents
FROM python:3.12-slim
# =============================================================================
# SECTION 1: System Dependencies
# =============================================================================
# Install required system packages for Python packages and Neo4j driver
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
build-essential \
gcc \
libssl-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# =============================================================================
# SECTION 2: Working Directory
# =============================================================================
WORKDIR /app
# =============================================================================
# SECTION 3: Python Dependencies
# =============================================================================
# Copy and install requirements first for better layer caching
COPY requirements.txt /app/requirements.txt
# Create requirements.txt if it doesn't exist (fallback for initial setup)
RUN if [ ! -f /app/requirements.txt ] || [ ! -s /app/requirements.txt ]; then \
echo "# OpenClaw Multi-Agent System Dependencies" > /app/requirements.txt && \
echo "neo4j>=5.15.0" >> /app/requirements.txt && \
echo "pydantic>=2.5.0" >> /app/requirements.txt && \
echo "httpx>=0.25.0" >> /app/requirements.txt && \
echo "python-dotenv>=1.0.0" >> /app/requirements.txt && \
echo "structlog>=23.2.0" >> /app/requirements.txt && \
echo "tenacity>=8.2.0" >> /app/requirements.txt && \
echo "pyyaml>=6.0.1" >> /app/requirements.txt; \
fi
RUN pip install --no-cache-dir -r /app/requirements.txt
# =============================================================================
# SECTION 4: Agent Directory Structure
# =============================================================================
# Create all 6 agent directories under /data/.clawdbot/agents/
# These directories store agent-specific state and configuration
RUN mkdir -p /data/.clawdbot/agents/main \
&& mkdir -p /data/.clawdbot/agents/researcher \
&& mkdir -p /data/.clawdbot/agents/writer \
&& mkdir -p /data/.clawdbot/agents/developer \
&& mkdir -p /data/.clawdbot/agents/analyst \
&& mkdir -p /data/.clawdbot/agents/ops
# =============================================================================
# SECTION 5: Workspace Directory Structure
# =============================================================================
# Create workspace directories for agent "souls" and shared resources
# Souls contain agent identity, skills, and operational memory
RUN mkdir -p /data/workspace/souls/main \
&& mkdir -p /data/workspace/souls/researcher \
&& mkdir -p /data/workspace/souls/writer \
&& mkdir -p /data/workspace/souls/developer \
&& mkdir -p /data/workspace/souls/analyst \
&& mkdir -p /data/workspace/souls/ops \
&& mkdir -p /data/workspace/memory \
&& mkdir -p /data/workspace/logs \
&& mkdir -p /data/workspace/temp \
&& mkdir -p /data/workspace/backups
# =============================================================================
# SECTION 6: Additional State Directories
# =============================================================================
# Create directories for sessions, credentials, and configuration
RUN mkdir -p /data/.clawdbot/sessions \
&& mkdir -p /data/.clawdbot/credentials/signal \
&& mkdir -p /data/.clawdbot/skills \
&& mkdir -p /data/.clawdbot/migrations
# =============================================================================
# SECTION 7: Permissions
# =============================================================================
# Set proper ownership and permissions for all data directories
# Using UID 1000 for non-root user (standard practice)
RUN groupadd -r clawdbot -g 1000 \
&& useradd -r -g clawdbot -u 1000 clawdbot \
&& chown -R 1000:1000 /data \
&& chmod -R 755 /data/.clawdbot \
&& chmod -R 755 /data/workspace \
&& chmod 777 /data/workspace/temp \
&& chmod 777 /data/workspace/logs
# =============================================================================
# SECTION 8: Application Code
# =============================================================================
# Copy application code to the container
COPY --chown=1000:1000 . /app/
# =============================================================================
# SECTION 9: Non-Root User Setup
# =============================================================================
# Switch to non-root user for security
USER 1000:1000
# =============================================================================
# SECTION 10: Environment Variables
# =============================================================================
# Default environment variables (can be overridden at runtime)
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV CLAWDBOT_STATE_DIR=/data/.clawdbot
ENV CLAWDBOT_WORKSPACE_DIR=/data/workspace
ENV CLAWDBOT_LOG_LEVEL=info
# =============================================================================
# SECTION 11: Health Check
# =============================================================================
# Basic health check (customize based on your gateway port)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:18789/health || exit 1
# =============================================================================
# SECTION 12: Entry Point
# =============================================================================
# This container provides the agent configuration and protocols for OpenClaw.
# The actual OpenClaw gateway runs as a separate service.
# This container keeps running to provide file system access for agents.
EXPOSE 8080 18789
# Simple health check server to keep container running
CMD ["python", "/app/health_server.py"]