Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push build images for Alloy on tags of build-image/v* #625

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 103 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,107 @@
---
kind: pipeline
name: Create Linux build image
platform:
arch: amd64
os: linux
steps:
- commands:
- export IMAGE_TAG=${DRONE_TAG##build-image/v}
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --name multiarch --driver docker-container --use
- docker buildx build --build-arg="GO_RUNTIME=golang:1.22.1-bullseye" --push --platform
linux/amd64,linux/arm64 -t grafana/alloy-build-image:$IMAGE_TAG ./tools/build-image
environment:
DOCKER_LOGIN:
from_secret: docker_login
DOCKER_PASSWORD:
from_secret: docker_password
image: docker
name: Build
volumes:
- name: docker
path: /var/run/docker.sock
trigger:
event:
- tag
ref:
- refs/tags/build-image/v*
type: docker
volumes:
- host:
path: /var/run/docker.sock
name: docker
---
kind: pipeline
name: Create Linux build image for boringcrypto
platform:
arch: amd64
os: linux
steps:
- commands:
- export IMAGE_TAG=${DRONE_TAG##build-image/v}-boringcrypto
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --name multiarch --driver docker-container --use
- docker buildx build --build-arg="GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.22.1-bullseye"
--push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:$IMAGE_TAG
./tools/build-image
environment:
DOCKER_LOGIN:
from_secret: docker_login
DOCKER_PASSWORD:
from_secret: docker_password
image: docker
name: Build
volumes:
- name: docker
path: /var/run/docker.sock
trigger:
event:
- tag
ref:
- refs/tags/build-image/v*
type: docker
volumes:
- host:
path: /var/run/docker.sock
name: docker
---
kind: pipeline
name: Create Windows build image
platform:
arch: amd64
os: windows
version: "1809"
steps:
- commands:
- $IMAGE_TAG="${DRONE_TAG##build-image/v}-windows"
- docker login -u $Env:DOCKER_LOGIN -p $Env:DOCKER_PASSWORD
- docker build -t grafana/alloy-build-image:$IMAGE_TAG ./tools/build-image/windows
- docker push grafana/alloy-build-image:$IMAGE_TAG
environment:
DOCKER_LOGIN:
from_secret: docker_login
DOCKER_PASSWORD:
from_secret: docker_password
image: docker:windowsservercore-1809
name: Build
volumes:
- name: docker
path: //./pipe/docker_engine/
trigger:
event:
- tag
ref:
- refs/tags/build-image/v*
type: docker
volumes:
- host:
path: //./pipe/docker_engine/
name: docker
---
kind: pipeline
name: Lint
platform:
arch: amd64
Expand Down Expand Up @@ -565,6 +667,6 @@ kind: secret
name: updater_private_key
---
kind: signature
hmac: 3484a2c2210641cb0e653616c7100ec52f49cb68c7f20647248de013e0da1826
hmac: b8a4493d643d2f8f0f8fac5bfa627473eb28219f7a6e6a623366c35b7e549e08

...
18 changes: 8 additions & 10 deletions .drone/pipelines/build_images.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ local locals = {
// TODO(rfratto): The following are temporarily diasbled as grafana/alloy
// gets set up.

/*
pipelines.linux('Create Linux build image') {
trigger: locals.on_build_image_tag,
steps: [{
Expand All @@ -32,11 +31,11 @@ local locals = {
}],
environment: locals.docker_environment,
commands: [
'export IMAGE_TAG=${DRONE_TAG##build-image/v}',
'export IMAGE_TAG=${DRONE_TAG##build-image/}',
'docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD',
'docker run --rm --privileged multiarch/qemu-user-static --reset -p yes',
'docker buildx create --name multiarch --driver docker-container --use',
'docker buildx build --build-arg="GO_RUNTIME=golang:1.22.1-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/agent-build-image:$IMAGE_TAG ./tools/build-image',
'docker buildx build --build-arg="GO_RUNTIME=golang:1.22.1-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:$IMAGE_TAG ./tools/build-image',
],
}],
volumes: [{
Expand All @@ -55,18 +54,18 @@ local locals = {
}],
environment: locals.docker_environment,
commands: [
'export IMAGE_TAG=${DRONE_TAG##build-image/v}-boringcrypto',
'export IMAGE_TAG=${DRONE_TAG##build-image/}-boringcrypto',
'docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD',
'docker run --rm --privileged multiarch/qemu-user-static --reset -p yes',
'docker buildx create --name multiarch --driver docker-container --use',
'docker buildx build --build-arg="GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.22.1-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/agent-build-image:$IMAGE_TAG ./tools/build-image',
'docker buildx build --build-arg="GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.22.1-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:$IMAGE_TAG ./tools/build-image',
],
}],
volumes: [{
name: 'docker',
host: { path: '/var/run/docker.sock' },
}],
},
},

pipelines.windows('Create Windows build image') {
trigger: locals.on_build_image_tag,
Expand All @@ -81,16 +80,15 @@ local locals = {
commands: [
// NOTE(rfratto): the variable syntax is parsed ahead of time by Drone,
// and not by Windows (where the syntax obviously wouldn't work).
'$IMAGE_TAG="${DRONE_TAG##build-image/v}-windows"',
'$IMAGE_TAG="${DRONE_TAG##build-image/}-windows"',
'docker login -u $Env:DOCKER_LOGIN -p $Env:DOCKER_PASSWORD',
'docker build -t grafana/agent-build-image:$IMAGE_TAG ./tools/build-image/windows',
'docker push grafana/agent-build-image:$IMAGE_TAG',
'docker build -t grafana/alloy-build-image:$IMAGE_TAG ./tools/build-image/windows',
'docker push grafana/alloy-build-image:$IMAGE_TAG',
],
}],
volumes: [{
name: 'docker',
host: { path: '//./pipe/docker_engine/' },
}],
},
*/
]
17 changes: 7 additions & 10 deletions tools/build-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
The Grafana Alloy build images are used for CI workflows to manage builds of
Grafana Alloy.

There are two images:
There are the following images:

* `grafana/alloy-build-image:X.Y.Z` (for building Linux containers)
* `grafana/alloy-build-image:X.Y.Z-windows` (for building Windows containers)
* `grafana/alloy-build-image:vX.Y.Z` (for building Linux containers)
* `grafana/alloy-build-image:vX.Y.Z-boringcrypto` (for building Linux containers with boringcrypto)
* `grafana/alloy-build-image:vX.Y.Z-windows` (for building Windows containers)
rfratto marked this conversation as resolved.
Show resolved Hide resolved

(Where `X.Y.Z` is replaced with some semantic version, like 0.14.0).
(Where `X.Y.Z` is replaced with some semantic version, like 0.1.0).

## Pushing new images

Once a commit is merged to main which updates the build-image Dockerfiles, a
maintainer must push a tag matching the pattern `build-image/vX.Y.Z` to the
grafana/alloy repo. For example, to create version v0.15.0 of the build images,
a maintainer would push the tag `build-image/v0.15.0`.

> **NOTE**: The tag name is expected to be prefixed with `v`, but the pushed
> images have the v prefix removed.
grafana/alloy repo. For example, to create version v0.1.0 of the build images,
a maintainer would push the tag `build-image/v0.1.0`.

Automation will trigger off of this tag being pushed, building and pushing the
new build images to Docker Hub.

A follow-up commit to use the newly pushed build images must be made.

Loading