update
Browse files- Dockerfile +1 -1
- Dockerfile copy +43 -0
Dockerfile
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
FROM node:20
|
| 3 |
|
| 4 |
# ---------- 2. 系统级依赖 ----------
|
| 5 |
-
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
# ---------- 3. 创建非 root 用户 ----------
|
| 8 |
RUN groupadd -r -g 1001 opencode && \
|
|
|
|
| 2 |
FROM node:20
|
| 3 |
|
| 4 |
# ---------- 2. 系统级依赖 ----------
|
| 5 |
+
RUN apt-get update && apt-get install -y git curl cron && rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
# ---------- 3. 创建非 root 用户 ----------
|
| 8 |
RUN groupadd -r -g 1001 opencode && \
|
Dockerfile copy
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---------- 1. 基础镜像 ----------
|
| 2 |
+
FROM node:20
|
| 3 |
+
|
| 4 |
+
# ---------- 2. 系统级依赖 ----------
|
| 5 |
+
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# ---------- 3. 创建非 root 用户 ----------
|
| 8 |
+
RUN groupadd -r -g 1001 opencode && \
|
| 9 |
+
useradd -r -g opencode -u 1001 opencode && \
|
| 10 |
+
mkdir -p /home/opencode && \
|
| 11 |
+
chown opencode:opencode /home/opencode
|
| 12 |
+
|
| 13 |
+
# ---------- 5. 全局安装 opencode-ai ----------
|
| 14 |
+
# 安装完先验证二进制是否存在,若不存在就手动解压
|
| 15 |
+
RUN npm install -g opencode-ai@latest && \
|
| 16 |
+
if [ ! -f /usr/local/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode ]; then \
|
| 17 |
+
cd /usr/local/lib/node_modules/opencode-ai && \
|
| 18 |
+
npm run postinstall; \
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
+
# ---------- 6. 工作目录 ----------
|
| 22 |
+
WORKDIR /app
|
| 23 |
+
COPY --chown=opencode:opencode package*.json ./
|
| 24 |
+
COPY --chown=opencode:opencode . /app
|
| 25 |
+
RUN if [ -f package.json ]; then npm ci --only=production; fi
|
| 26 |
+
|
| 27 |
+
# ---------- 7. 修正权限 ----------
|
| 28 |
+
RUN chown -R opencode:opencode /app /home/opencode
|
| 29 |
+
|
| 30 |
+
# ---------- 8. 启动脚本 ----------
|
| 31 |
+
USER opencode
|
| 32 |
+
RUN mkdir -p /home/opencode/.local/bin
|
| 33 |
+
RUN printf '#!/bin/sh\n\
|
| 34 |
+
echo "Starting OpenCode AI Web Server ..."\n\
|
| 35 |
+
exec /usr/local/bin/opencode serve --hostname 0.0.0.0 --port 7860\n' > /home/opencode/.local/bin/start.sh && \
|
| 36 |
+
chmod +x /home/opencode/.local/bin/start.sh
|
| 37 |
+
|
| 38 |
+
# ---------- 9. 端口与健康检查 ----------
|
| 39 |
+
EXPOSE 7860
|
| 40 |
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 41 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 42 |
+
|
| 43 |
+
CMD ["/home/opencode/.local/bin/start.sh"]
|