woodpecker/docs/versioned_docs/version-3.0/92-development/07-guides.md
Patrick Schratz bdf753f678
Add docs for 3.0 (#4705)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: qwerty287 <qwerty287@posteo.de>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-authored-by: Anbraten <anton@ju60.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com>
2025-01-18 20:39:06 +01:00

2.5 KiB

Guides

ORM

Woodpecker uses Xorm as ORM for the database connection.

Add a new migration

Woodpecker uses migrations to change the database schema if a database model has been changed. Add the new migration task into server/store/datastore/migration/.

:::info Adding new properties to models will be handled automatically by the underlying ORM based on the struct field tags of the model. If you add a completely new model, you have to add it to the allBeans variable at server/store/datastore/migration/migration.go to get a new table created. :::

:::warning You should not use sess.Begin(), sess.Commit() or sess.Close() inside a migration. Session / transaction handling will be done by the underlying migration manager. :::

To automatically execute the migration after the start of the server, the new migration needs to be added to the end of migrationTasks in server/store/datastore/migration/migration.go. After a successful execution of that transaction the server will automatically add the migration to a list, so it won't be executed again on the next start.

Constants of official images

All official default images, are saved in shared/constant/constant.go and must be pinned by an exact tag.

Building images locally

Server

### build web component
make vendor
cd web/
pnpm install --frozen-lockfile
pnpm build
cd ..

### define the platforms to build for (e.g. linux/amd64)
# (the | is not a typo here)
export PLATFORMS='linux|amd64'
make cross-compile-server

### build the image
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.server.multiarch.rootless --push .

:::info The cross-compile-server rule makes use of xgo, a go cross-compiler. You need to be on a amd64 host to do this, as xgo is only available for amd64 (see xgo#213). You can try to use the build-server rule instead, however this one fails for some OS (e.g. macOS). :::

Agent

### build the agent
make build-agent

### build the image
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.agent.multiarch --push .

CLI

### build the CLI
make build-cli

### build the image
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.cli.multiarch.rootless --push .