Compare commits
2
Commits
9058149576
...
5f491edff4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f491edff4 | ||
|
|
d03e024d59 |
No files matched your search
@@ -0,0 +1,57 @@
|
||||
# hxtesting 测试服自动部署
|
||||
# 触发:push 到 main(同事更新代码后自动构建部署),也支持手动触发
|
||||
# 执行:hxtesting 宿主上的 gitea-runner(label=deploy-host,host 模式)
|
||||
# 说明:构建 app/frontend 镜像并顶替同名 latest tag,docreader/sandbox 等沿用官方镜像;
|
||||
# 每次构建额外打 sha-<短提交> tag 便于回滚。
|
||||
name: deploy-hxtesting
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: deploy-host
|
||||
timeout-minutes: 40
|
||||
env:
|
||||
DEPLOY_DIR: /home/lisq/services/ai_academy
|
||||
steps:
|
||||
- name: 同步代码
|
||||
run: |
|
||||
set -e
|
||||
cd "$DEPLOY_DIR"
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
echo "GIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
||||
echo "当前部署提交: $(git log --oneline -1)"
|
||||
|
||||
- name: 构建镜像(app + frontend,ARM64 原生)
|
||||
run: |
|
||||
set -e
|
||||
cd "$DEPLOY_DIR"
|
||||
# WITH_ANYDOC=0:跳过 anydoc 解析引擎(Rust 工具链需外网,hxtesting 不可达;
|
||||
# 文档解析由 docreader 容器承担,测试环境不受影响)
|
||||
WITH_ANYDOC=0 bash scripts/build_images.sh -p
|
||||
WITH_ANYDOC=0 bash scripts/build_images.sh -f
|
||||
docker tag wechatopenai/weknora-app:latest wechatopenai/weknora-app:sha-${GIT_SHA}
|
||||
docker tag wechatopenai/weknora-ui:latest wechatopenai/weknora-ui:sha-${GIT_SHA}
|
||||
docker image prune -f --filter "until=168h" >/dev/null
|
||||
|
||||
- name: 部署(compose up)
|
||||
run: |
|
||||
set -e
|
||||
cd "$DEPLOY_DIR"
|
||||
docker compose up -d --remove-orphans
|
||||
|
||||
- name: 健康检查
|
||||
run: |
|
||||
set -e
|
||||
sleep 20
|
||||
if curl -fsS -o /dev/null --max-time 10 http://127.0.0.1/; then
|
||||
echo "WEB_OK: http://hxtesting/ 已可访问 (sha-${GIT_SHA})"
|
||||
else
|
||||
echo "健康检查失败,容器状态:"
|
||||
cd "$DEPLOY_DIR" && docker compose ps
|
||||
exit 1
|
||||
fi
|
||||
@@ -6,6 +6,7 @@
|
||||
!.gitignore
|
||||
!.gitattributes
|
||||
!.github/
|
||||
!.gitea/
|
||||
!.dockerignore
|
||||
!.golangci.yml
|
||||
!.air.toml
|
||||
|
||||
@@ -55,7 +55,7 @@ RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate
|
||||
# so that module's go.mod must exist before `go mod download`.
|
||||
COPY go.mod go.sum ./
|
||||
COPY third_party/anydoc-go/go.mod third_party/anydoc-go/go.mod
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
RUN go mod download
|
||||
COPY cmd/download cmd/download
|
||||
# DuckDB extensions (spatial/excel): prefer a local seed tarball exported from
|
||||
# a previously built image (artifacts/duckdb_extensions/seed.tar) —
|
||||
@@ -69,7 +69,7 @@ RUN if [ -s /tmp/duckdb-seed.tar ]; then \
|
||||
go run cmd/download/duckdb/duckdb.go; \
|
||||
fi
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=/go/pkg/mod bash ./scripts/copy-licenses.sh /license-bundle
|
||||
RUN bash ./scripts/copy-licenses.sh /license-bundle
|
||||
|
||||
# Get version and commit info for build injection
|
||||
ARG VERSION_ARG
|
||||
@@ -119,14 +119,12 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
# the layer (~2.7 GB), which occupies disk locally and is uploaded to the CI
|
||||
# layer cache. Mounted, the cache lives outside the layer and repeated builds
|
||||
# reuse compiled objects instead of recompiling from scratch.
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
if [ "$WITH_ANYDOC" = "1" ]; then \
|
||||
RUN if [ "$WITH_ANYDOC" = "1" ]; then \
|
||||
make build-prod GO_BUILD_TAGS=anydoc; \
|
||||
else \
|
||||
make build-prod; \
|
||||
fi
|
||||
RUN --mount=type=cache,target=/go/pkg/mod cp -r /go/pkg/mod/github.com/yanyiwu/ /app/yanyiwu/
|
||||
RUN cp -r /go/pkg/mod/github.com/yanyiwu/ /app/yanyiwu/
|
||||
|
||||
# Final stage
|
||||
FROM debian:12.12-slim
|
||||
|
||||
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Reference in new issue
Block a user