xlyu0523 commited on
Commit
847098c
·
verified ·
1 Parent(s): 4e9b719

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -16
Dockerfile CHANGED
@@ -45,20 +45,20 @@ RUN uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir \
45
  && chmod 0440 /etc/sudoers.d/hermes \
46
  && /usr/sbin/visudo -cf /etc/sudoers.d/hermes
47
 
48
- # 3. 复制魔改项目的全部核心组件并【强制洗刷换行符】
49
- COPY --chown=hermes:hermes start.sh /opt/huggingmes/start.sh
50
- COPY --chown=hermes:hermes health-server.js /opt/huggingmes/health-server.js
51
- COPY --chown=hermes:hermes cloudflare-proxy-setup.py /opt/huggingmes/cloudflare-proxy-setup.py
52
- COPY --chown=hermes:hermes cloudflare-keepalive-setup.py /opt/huggingmes/cloudflare-keepalive-setup.py
53
- COPY --chown=hermes:hermes env-builder.html /opt/huggingmes/env-builder.html
54
- COPY --chown=hermes:hermes env-builder.js /opt/huggingmes/env-builder.js
55
-
56
- # CRITICAL FIX: 强刷去除可能由于 Windows 编辑带来的 \r 换行符污染
 
 
57
  RUN sed -i 's/\r$//' /opt/huggingmes/start.sh && \
58
- chmod +x \
59
- /opt/huggingmes/start.sh \
60
- /opt/huggingmes/cloudflare-proxy-setup.py \
61
- /opt/huggingmes/cloudflare-keepalive-setup.py
62
 
63
  # 4. 保留原项目看板数据库迁移幂等补丁
64
  RUN python3 - <<'PY'
@@ -107,7 +107,10 @@ PY
107
  RUN echo 'export PATH="/opt/hermes/.venv/bin:/opt/data/.local/bin:$PATH"' \
108
  > /etc/profile.d/hermes-venv.sh
109
 
110
- # 环境变量修正:完全对齐官方与魔改共存工作空间路径
 
 
 
111
  ENV HERMES_HOME=/opt/data \
112
  HUGGINGMES_APP_DIR=/opt/huggingmes \
113
  HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
@@ -120,5 +123,5 @@ EXPOSE 7861
120
  HEALTHCHECK --interval=30s --timeout=5s --start-period=60s \
121
  CMD curl -fsS http://localhost:7861/health || exit 1
122
 
123
- # 以 root 入口显式通过 bash 驱动防止底层 s6 管理器因不可见标识符再次 exec 失败
124
- CMD ["/bin/bash", "/opt/huggingmes/start.sh"]
 
45
  && chmod 0440 /etc/sudoers.d/hermes \
46
  && /usr/sbin/visudo -cf /etc/sudoers.d/hermes
47
 
48
+ # 3. 复制魔改项目的全部核心组件
49
+ COPY start.sh /opt/huggingmes/start.sh
50
+ COPY health-server.js /opt/huggingmes/health-server.js
51
+ COPY cloudflare-proxy-setup.py /opt/huggingmes/cloudflare-proxy-setup.py
52
+ COPY cloudflare-keepalive-setup.py /opt/huggingmes/cloudflare-keepalive-setup.py
53
+ COPY env-builder.html /opt/huggingmes/env-builder.html
54
+ COPY env-builder.js /opt/huggingmes/env-builder.js
55
+
56
+ # CRITICAL ROOTLESS FIX:
57
+ # 1. 强力抹除 Windows 换行符。
58
+ # 2. 对整个工作空间刷成 777,确保在任何低权限随机 UID 下进程都有完全的绝对读写和执行权。
59
  RUN sed -i 's/\r$//' /opt/huggingmes/start.sh && \
60
+ chmod -R 777 /opt/huggingmes && \
61
+ mkdir -p /opt/data && chmod -R 777 /opt/data
 
 
62
 
63
  # 4. 保留原项目看板数据库迁移幂等补丁
64
  RUN python3 - <<'PY'
 
107
  RUN echo 'export PATH="/opt/hermes/.venv/bin:/opt/data/.local/bin:$PATH"' \
108
  > /etc/profile.d/hermes-venv.sh
109
 
110
+ # 恢复官方默认普通用户身份,顺应底层容器集群的沙箱降权安全策略
111
+ USER hermes
112
+
113
+ # 恢复官方底座的标准环境变量
114
  ENV HERMES_HOME=/opt/data \
115
  HUGGINGMES_APP_DIR=/opt/huggingmes \
116
  HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
 
123
  HEALTHCHECK --interval=30s --timeout=5s --start-period=60s \
124
  CMD curl -fsS http://localhost:7861/health || exit 1
125
 
126
+ # 顺应官方底座的启动入口,将我们的 start.sh 挂载为业务服务的主入口
127
+ CMD ["/opt/huggingmes/start.sh"]