Skip to content

Commit

Permalink
Add GitHub Actions steps for creating Linux build images. (grafana#2532)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptodev authored Jan 27, 2025
1 parent 8d9c4bc commit e621c94
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 103 deletions.
103 changes: 0 additions & 103 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,3 @@
---
kind: pipeline
name: Create Linux build image
platform:
arch: amd64
os: linux
steps:
- commands:
- 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.23.5-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/}-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.23.5-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/}-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:
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/create_build_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Create build images
on:
push:
tags:
- build-image/v*

permissions:
contents: read
id-token: write

jobs:
linux_build_image:
name: Create a Linux build image
runs-on:
labels: github-hosted-ubuntu-x64-small
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false

- name: Get version from Git tag
env:
FULL_TAG: ${{ github.ref_name }}
id: get_image_version
run: echo "image_tag=${FULL_TAG##*/}" >> $GITHUB_OUTPUT

- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]

- run: |
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.23.5-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:${{ steps.get_image_version.outputs.image_tag }} ./tools/build-image
linux_build_image_boringcrypto:
name: Create a Linux build image for boringcrypto
runs-on:
labels: github-hosted-ubuntu-x64-small
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false

- name: Get version from Git tag
env:
FULL_TAG: ${{ github.ref_name }}
id: get_image_version
run: echo "image_tag=${FULL_TAG##*/}-boringcrypto" >> $GITHUB_OUTPUT

- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]

- run: |
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.23.5-bullseye" --push --platform linux/amd64,linux/arm64 -t grafana/alloy-build-image:${{ steps.get_image_version.outputs.image_tag }} ./tools/build-image

0 comments on commit e621c94

Please sign in to comment.