Compare commits
3 Commits
1006e8a71e
...
b99f6325d5
| Author | SHA1 | Date |
|---|---|---|
|
|
b99f6325d5 | |
|
|
0a677d17da | |
|
|
3f5c2bb137 |
54
.drone.yml
54
.drone.yml
|
|
@ -23,9 +23,32 @@ steps:
|
|||
- apk add --no-cache openjdk21-jdk maven postgresql-client
|
||||
- mvn -B -ntp -f backend/pom.xml verify
|
||||
- sh deploy/local/ci-smoke.sh
|
||||
trigger:
|
||||
event: [push, pull_request, tag]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: backend-publish
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
node:
|
||||
atlas-release: "true"
|
||||
|
||||
depends_on:
|
||||
- backend-ci
|
||||
|
||||
steps:
|
||||
- name: package
|
||||
image: maven:3.9.11-eclipse-temurin-21-alpine
|
||||
commands:
|
||||
- mvn -B -ntp -f backend/pom.xml -DskipTests package
|
||||
- name: publish-gateway
|
||||
image: plugins/docker:21.3.8
|
||||
depends_on: [verify]
|
||||
depends_on: [package]
|
||||
settings:
|
||||
registry: git.tutudog.com
|
||||
repo: git.tutudog.com/dongjf/item-atlas-gateway
|
||||
|
|
@ -37,9 +60,6 @@ steps:
|
|||
context: backend/gateway
|
||||
platform: linux/arm64
|
||||
tags: ["${DRONE_COMMIT_SHA}"]
|
||||
when:
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
- name: publish-inventory-service
|
||||
image: plugins/docker:21.3.8
|
||||
depends_on: [publish-gateway]
|
||||
|
|
@ -54,9 +74,6 @@ steps:
|
|||
context: backend/inventory-service
|
||||
platform: linux/arm64
|
||||
tags: ["${DRONE_COMMIT_SHA}"]
|
||||
when:
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
- name: publish-intake-service
|
||||
image: plugins/docker:21.3.8
|
||||
depends_on: [publish-inventory-service]
|
||||
|
|
@ -71,24 +88,27 @@ steps:
|
|||
context: backend/intake-service
|
||||
platform: linux/arm64
|
||||
tags: ["${DRONE_COMMIT_SHA}"]
|
||||
when:
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
trigger:
|
||||
event: [push, pull_request, tag]
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: deploy-staging
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
node:
|
||||
atlas-deploy: "true"
|
||||
atlas-release: "true"
|
||||
|
||||
steps:
|
||||
- name: helm-upgrade
|
||||
image: alpine/helm:3.20.0
|
||||
environment:
|
||||
HELM_DRIVER: configmap
|
||||
ATLAS_KUBECONFIG_B64:
|
||||
from_secret: atlas_staging_kubeconfig_b64
|
||||
commands:
|
||||
|
|
@ -97,14 +117,19 @@ steps:
|
|||
trigger:
|
||||
event: [promote]
|
||||
target: [staging]
|
||||
ref: [refs/tags/v*]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: deploy-production
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
node:
|
||||
atlas-deploy: "true"
|
||||
atlas-release: "true"
|
||||
|
||||
steps:
|
||||
- name: helm-upgrade
|
||||
|
|
@ -118,3 +143,6 @@ steps:
|
|||
trigger:
|
||||
event: [promote]
|
||||
target: [production]
|
||||
ref:
|
||||
include: [refs/tags/v*]
|
||||
exclude: [refs/tags/v*-*]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ from urllib.parse import urlencode
|
|||
from urllib.request import Request, urlopen
|
||||
|
||||
BASE = os.environ.get("ATLAS_BASE_URL", "http://127.0.0.1:8080").rstrip("/")
|
||||
PASSWORD = os.environ["ATLAS_LOCAL_PASSWORD"]
|
||||
PASSWORD = os.environ.get("ATLAS_LOCAL_PASSWORD")
|
||||
TOKENS = {name: os.environ.get("ATLAS_SMOKE_TOKEN_" + name.upper())
|
||||
for name in ("owner", "viewer", "other")}
|
||||
if not (all(TOKENS.values()) or PASSWORD and not any(TOKENS.values())):
|
||||
raise ValueError("Supply ATLAS_LOCAL_PASSWORD or the three staging access tokens")
|
||||
HOUSE = "/api/households/00000000-0000-0000-0000-000000000001"
|
||||
OTHER_HOUSE = "/api/households/00000000-0000-0000-0000-000000000002"
|
||||
RUN = uuid.uuid4().hex[:8]
|
||||
|
|
@ -22,8 +26,11 @@ def call(method, path, payload=None, *, user="owner", status=200):
|
|||
if data is not None:
|
||||
request.add_header("Content-Type", "application/json")
|
||||
if user:
|
||||
token = base64.b64encode(f"{user}:{PASSWORD}".encode()).decode()
|
||||
request.add_header("Authorization", f"Basic {token}")
|
||||
if TOKENS[user]:
|
||||
request.add_header("Authorization", f"Bearer {TOKENS[user]}")
|
||||
else:
|
||||
token = base64.b64encode(f"{user}:{PASSWORD}".encode()).decode()
|
||||
request.add_header("Authorization", f"Basic {token}")
|
||||
try:
|
||||
response = urlopen(request, timeout=78)
|
||||
except HTTPError as error:
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
## 从提交到部署
|
||||
|
||||
1. Gitea 保存代码。Drone `backend-ci` 在常规提交和发布标签上运行 Java 21、Maven 和 API 冒烟。CI 使用 runner 已缓存的 PostgreSQL 15 镜像做兼容验证,本地和目标部署使用 PostgreSQL 17。发布标签采用 `v*`。标签验证通过后构建并推送三个 ARM64 镜像,镜像标签使用完整提交 SHA。
|
||||
1. Gitea 保存代码。Drone `backend-ci` 在常规提交和发布标签上运行 Java 21、Maven 和 API 冒烟。CI 用 PostgreSQL 15 做兼容验证,本地和部署环境用 PostgreSQL 17。对 `v*` 标签,CI 通过后 ARM64 runner 构建并推送三个镜像。镜像标签取自 Drone 构建的 `DRONE_COMMIT_SHA`。Gitea 发送附注标签事件时,这个值可能是标签对象 SHA,部署沿用源构建的同一个值。
|
||||
2. 在 Drone 提升同一个成功构建到 `staging`。部署步骤使用 Helm 3 的 `upgrade --install --atomic --wait`。就绪探针检查应用和数据库,Helm hook 逐个访问 Kubernetes Service。
|
||||
3. 在预发布验证业务请求,再将同一个构建提升到 `production`。正式端口由既有入口配置转发到网关。数据库、Ollama 与 Actuator 保持内部访问。
|
||||
3. 在预发布验证业务请求。正式发布使用同一稳定版本构建与 `production` 提升,带连字符的候选标签只走预发布。正式端口由入口配置转发到网关。数据库、Ollama 与 Actuator 保持内部访问。
|
||||
|
||||
标记 `atlas-deploy=true` 的 Drone runner 须能通过内网访问对应 Kubernetes API。分环境创建 Kubernetes namespace 和作用域受限的发布身份。用 Drone Secrets 提供仓库令牌和对应 namespace 的 kubeconfig。集群内的镜像拉取使用 `item-atlas-registry`。 [Drone Promotion](https://docs.drone.io/user-guide/pipeline/promotion/) · [Helm 升级](https://helm.sh/docs/v3/helm/helm_upgrade/)
|
||||
标记 `atlas-release=true` 的 ARM64 runner 负责镜像构建和部署,只接收本项目的标签及提升事件。部署时须能访问对应 Kubernetes API。分环境创建 namespace 和作用域受限的发布身份。预发布用 ConfigMap 存 Helm 修订,部署账号可维护应用资源。Drone Secrets 保存仓库令牌与分环境的 kubeconfig。集群用 `item-atlas-registry` 拉取镜像。 [Drone Runner 路由](https://docs.drone.io/user-guide/pipeline/nodes/) · [Drone Promotion](https://docs.drone.io/user-guide/pipeline/promotion/) · [Helm 升级](https://helm.sh/docs/v3/helm/helm_upgrade/)
|
||||
|
||||
| 位置 | 配置 |
|
||||
| --- | --- |
|
||||
|
|
@ -16,7 +16,17 @@
|
|||
| PostgreSQL | 为两个服务各建一个数据库和登录角色。数据卷在 SSD。首次启动由 Flyway 建表。 |
|
||||
| Ollama | 录入服务设置 `ATLAS_OLLAMA_ENABLED=true` 和内网 `ATLAS_OLLAMA_URL`,模型默认 `gemma4:12b`。 |
|
||||
|
||||
正式数据库使用 `release` 配置,家庭成员按 OIDC `sub` 建立记录。演示数据用单独数据库。首期需要开通家庭时,由管理员在数据库维护窗口建立 `household` 和 `household_member` 对应行。
|
||||
## 预发布验收
|
||||
|
||||
预发布使用独立的 Kubernetes 命名空间、数据卷和 OIDC realm。使用 Keycloak 时,给客户端配置 `item-atlas-api` audience 和 `sub` 声明。客户端登录走授权码和 PKCE,录入服务的机器凭证另配 `atlas.deliver` scope。通过临时端口转发访问测试登录页和网关,预发布数据库、身份服务和 Ollama 留在内网。 [Keycloak 服务配置](https://www.keycloak.org/server/containers)
|
||||
|
||||
后端使用 `release` 配置。按 [冒烟脚本](../../backend/tests/smoke.py) 中的两个固定 ID 建立测试家庭,再把验收账号的 OIDC `sub` 对应到 `household_member`。准备管理员、只读成员和另一家庭的三个临时 access token,分别注入 `ATLAS_SMOKE_TOKEN_OWNER`、`ATLAS_SMOKE_TOKEN_VIEWER`、`ATLAS_SMOKE_TOKEN_OTHER`,然后从仓库根目录运行。
|
||||
|
||||
```sh
|
||||
ATLAS_BASE_URL=http://127.0.0.1:18380 ATLAS_EXPECT_MODEL=1 python3 backend/tests/smoke.py
|
||||
```
|
||||
|
||||
检查三个服务的就绪状态及实际运行镜像摘要,再检查冒烟输出。验收覆盖家庭隔离、物品查询与移动、本地模型草稿、并发确认和一次写入。
|
||||
|
||||
## 灰度
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue