指南
ORM
Woodpecker 使用 Xorm 作为数据库连接的 ORM。
添加新迁移
如果数据库模型发生更改,Woodpecker 使用迁移来更改数据库架构。将新的迁移任务添加到 server/store/datastore/migration/ 中。
信息
注意
您不应该在迁移中使用 sess.Begin()、sess.Commit() 或 sess.Close()。会话/事务处理将由底层迁移管理器完成。
要在服务器启动后自动执行迁移,需要将新迁移添加到 server/store/datastore/migration/migration.go 中 migrationTasks 的末尾。成功执行该事务后,服务器将自动将迁移添加到列表中,因此在下次启动时不会再次执行。
官方镜像常量
所有官方默认镜像都保存在 shared/constant/constant.go 中,并且必须通过确切的标签固定。
本地构建镜像
服务器
### 构建 Web 组件
make vendor
cd web/
pnpm install --frozen-lockfile
pnpm build
cd ..
### 定义要构建的平台(例如 linux/amd64)
# (这里的 | 不是打字错误)
export PLATFORMS='linux|amd64'
make cross-compile-server
### 构建镜像
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.server.multiarch.rootless --push .
信息
cross-compile-server 规则使用 xgo,一个 go 交叉编译器。您需要在 amd64 主机上执行此操作,因为 xgo 仅适用于 amd64(参见 xgo#213)。
您可以尝试使用 build-server 规则,但是对于某些操作系统(例如 macOS),此规则会失败。
代理
### 构建代理
make build-agent
### 构建镜像
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.agent.multiarch --push .
CLI
### 构建 CLI
make build-cli
### 构建镜像
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.cli.multiarch.rootless --push .