Add instructions how to build images locally (#4277)

This commit is contained in:
Patrick Schratz 2024-10-30 16:08:31 +01:00 committed by GitHub
parent 3adcfb8b14
commit 322e386f36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,3 +21,49 @@ To automatically execute the migration after the start of the server, the new mi
## Constants of official images
All official default images, are saved in [shared/constant/constant.go](https://github.com/woodpecker-ci/woodpecker/blob/main/shared/constant/constant.go) and must be pinned by an exact tag.
## Building images locally
### Server
```sh
### 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 --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](https://github.com/techknowlogick/xgo/issues/213)).
You can try to use the `build-server` rule instead, however this one fails for some OS (e.g. macOS).
:::
### Agent
```sh
### 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
```sh
### build the CLI
make build-cli
### build the image
docker buildx build --platform linux/amd64 -t username/repo:tag -f docker/Dockerfile.cli.multiarch --push .
```