| |
| FROM node:20 |
|
|
| |
| RUN apt-get update && apt-get install -y git curl cron && rm -rf /var/lib/apt/lists/* |
|
|
| |
| |
|
|
| |
| |
| RUN npm install -g opencode-ai@latest && \ |
| if [ ! -f /usr/local/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode ]; then \ |
| cd /usr/local/lib/node_modules/opencode-ai && \ |
| npm run postinstall; \ |
| fi |
|
|
| |
| WORKDIR /app |
| COPY package*.json ./ |
| COPY . /app |
| RUN if [ -f package.json ]; then npm ci --only=production; fi |
|
|
| |
| RUN mkdir -p /usr/local/bin |
| RUN printf '#!/bin/sh\n\ |
| echo "Starting OpenCode AI Web Server ..."\n\ |
| # 启动 cron 服务\n\ |
| cron && \ |
| echo "Cron started successfully"\n\ |
| # 启动 opencode 服务\n\ |
| exec /usr/local/bin/opencode serve --hostname 0.0.0.0 --port 7860\n' > /usr/local/bin/start.sh && \ |
| chmod +x /usr/local/bin/start.sh |
|
|
| |
| EXPOSE 7860 |
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ |
| CMD curl -f http://localhost:7860/health || exit 1 |
|
|
| CMD ["/usr/local/bin/start.sh"] |