feat: add container CI/CD workflow
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
.git
|
.git
|
||||||
|
.gitea
|
||||||
node_modules
|
node_modules
|
||||||
.opencode/node_modules
|
.opencode/node_modules
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
.local.env
|
.local.env
|
||||||
dist
|
dist
|
||||||
.vscode
|
.vscode
|
||||||
|
data
|
||||||
|
logs
|
||||||
|
source
|
||||||
|
coverage
|
||||||
|
test-results
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
name: Agent CI/CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-test-publish-and-deploy:
|
||||||
|
uses: OrgTJWater/ci-templates/.gitea/workflows/container-cd.yml@main
|
||||||
|
with:
|
||||||
|
image_name: gitea.waternetwork.cn/orgtjwater/next-tjwater-agent
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_context: .
|
||||||
|
test_target: build
|
||||||
|
deploy_service: agent
|
||||||
|
deploy_host: 192.168.1.114
|
||||||
|
secrets:
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
DEV_DEPLOY_SSH_KEY: ${{ secrets.DEV_DEPLOY_SSH_KEY }}
|
||||||
+6
-10
@@ -1,6 +1,6 @@
|
|||||||
FROM oven/bun:canary-slim AS bun-bin
|
FROM oven/bun:canary-slim@sha256:24a8816a7388dd900e851b61b6d44a4a1908f464661a9ffe393e13e661f0ae3e AS bun-bin
|
||||||
|
|
||||||
FROM smanx/opencode:latest AS base
|
FROM smanx/opencode:1.18.13@sha256:b976acda21efffacd44abd7847dac7d646910dbaa477d1877e2881b39cf22a91 AS base
|
||||||
USER root
|
USER root
|
||||||
ARG UBUNTU_APT_MIRROR=mirrors.aliyun.com
|
ARG UBUNTU_APT_MIRROR=mirrors.aliyun.com
|
||||||
ARG PYPI_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
ARG PYPI_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
@@ -54,29 +54,25 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY --from=deps /app/.opencode/node_modules ./.opencode/node_modules
|
COPY --from=deps /app/.opencode/node_modules ./.opencode/node_modules
|
||||||
|
COPY package.json bun.lock ./
|
||||||
COPY tsconfig.json opencode.json README.md .gitignore ./
|
COPY tsconfig.json opencode.json README.md .gitignore ./
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY .opencode ./.opencode
|
COPY .opencode ./.opencode
|
||||||
RUN bun run check
|
RUN bun run check
|
||||||
|
|
||||||
FROM base AS runner
|
FROM build AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
ENV PORT=8787
|
ENV PORT=8787
|
||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
COPY --from=deps /app/.opencode/node_modules ./.opencode/node_modules
|
|
||||||
COPY package.json bun.lock ./
|
|
||||||
COPY tsconfig.json opencode.json .gitignore ./
|
|
||||||
COPY src ./src
|
|
||||||
COPY .opencode ./.opencode
|
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
EXPOSE 8787
|
EXPOSE 8787
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
||||||
|
CMD curl --fail --silent --show-error "http://127.0.0.1:${PORT}/health" >/dev/null || exit 1
|
||||||
CMD ["bun", "src/server.ts"]
|
CMD ["bun", "src/server.ts"]
|
||||||
|
|||||||
@@ -99,3 +99,14 @@ bun test tests/**/*.test.ts
|
|||||||
```
|
```
|
||||||
|
|
||||||
`bun run check` 会检查服务代码和 `.opencode` 工具的类型。
|
`bun run check` 会检查服务代码和 `.opencode` 工具的类型。
|
||||||
|
|
||||||
|
## CI/CD
|
||||||
|
|
||||||
|
Gitea Actions 通过 `.gitea/workflows/package.yml` 复用
|
||||||
|
`OrgTJWater/ci-templates` 的容器发布流程。手动触发只构建镜像并在 Dev
|
||||||
|
服务器运行候选验证;从 `main` 创建并推送 `v*` tag 后,候选验证通过才会
|
||||||
|
提升为正式 `agent` 服务。
|
||||||
|
|
||||||
|
仓库需要配置 `REGISTRY_USERNAME`、`REGISTRY_PASSWORD` 和
|
||||||
|
`DEV_DEPLOY_SSH_KEY` 三个 Gitea Secrets。`.env`、持久化数据、日志和
|
||||||
|
`source/` 业务数据不会写入镜像;它们由 Dev 服务器通过环境文件和卷挂载。
|
||||||
|
|||||||
Reference in New Issue
Block a user