@@ -36,68 +36,13 @@ RUN mkdir -p /var/lib/neo4j/data /var/lib/neo4j/logs /var/lib/neo4j/import /var/
3636COPY requirements.txt .
3737RUN pip install --no-cache-dir -r requirements.txt
3838
39+ # 复制启动脚本并设置权限
40+ COPY start.sh /app/start.sh
41+ RUN chmod +x /app/start.sh
42+
3943# 复制应用代码
4044COPY . .
4145
42- # 创建启动脚本
43- RUN echo '#!/bin/bash\n \
44- set -e\n \
45- \n \
46- # 确保清理旧的数据(如果需要重新初始化)\n \
47- if [ "$RESET_NEO4J" = "true" ]; then\n \
48- echo "Resetting Neo4j data..."\n \
49- rm -rf /var/lib/neo4j/data/databases/\n \
50- rm -rf /var/lib/neo4j/data/transactions/\n \
51- fi\n \
52- \n \
53- # 设置 Neo4j 初始密码\n \
54- echo "Setting up Neo4j initial password..."\n \
55- if [ ! -f /var/lib/neo4j/data/.neo4j_initialized ]; then\n \
56- neo4j-admin dbms set-initial-password ${NEO4J_PASSWORD:-password}\n \
57- touch /var/lib/neo4j/data/.neo4j_initialized\n \
58- else\n \
59- echo "Neo4j already initialized, skipping password setup"\n \
60- fi\n \
61- \n \
62- # 启动 Neo4j\n \
63- echo "Starting Neo4j..."\n \
64- neo4j start\n \
65- \n \
66- # 等待 Neo4j 启动\n \
67- echo "Waiting for Neo4j to start..."\n \
68- for i in {1..30}; do\n \
69- if neo4j status > /dev/null 2>&1; then\n \
70- echo "Neo4j started successfully"\n \
71- break\n \
72- fi\n \
73- echo "Neo4j is starting... ($i/30)"\n \
74- sleep 2\n \
75- done\n \
76- \n \
77- # 验证 Neo4j 是否真的启动了\n \
78- if ! neo4j status > /dev/null 2>&1; then\n \
79- echo "Failed to start Neo4j after 60 seconds"\n \
80- exit 1\n \
81- fi\n \
82- \n \
83- # 额外等待确保 Neo4j 完全就绪\n \
84- echo "Waiting for Neo4j to be fully ready..."\n \
85- sleep 5\n \
86- \n \
87- # 运行应用\n \
88- echo "Starting Graphiti MCP Server..."\n \
89- if [ -f "mcp_server.py" ]; then\n \
90- python mcp_server.py\n \
91- elif [ -f "main.py" ]; then\n \
92- python main.py\n \
93- elif [ -f "app.py" ]; then\n \
94- python app.py\n \
95- else\n \
96- echo "No application file found. Starting Python shell..."\n \
97- python\n \
98- fi\n \
99- ' > /app/start.sh && chmod +x /app/start.sh
100-
10146# 暴露端口
10247EXPOSE 7474 7687 8000
10348
@@ -106,4 +51,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
10651 CMD neo4j status && curl -f http://localhost:7474/ || exit 1
10752
10853# 启动命令
109- CMD ["/app /start.sh" ]
54+ CMD [". /start.sh" ]
0 commit comments