Skip to content

Commit

Permalink
feat: build the Docker Driver for arm64 (grafana#9247)
Browse files Browse the repository at this point in the history
Co-authored-by: Trevor Whitney <trevorjwhitney@gmail.com>
  • Loading branch information
2 people authored and thevops committed Nov 21, 2024
1 parent e3b00ee commit 4088d64
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"subdir": "workflows"
}
},
"version": "20aac53fcb06d378b1c1101c7e4dc989466eb4ff"
"version": "21f1189544e3976070cbdb6463f64c7a32dcc176"
}
],
"legacyImports": true
Expand Down
4 changes: 2 additions & 2 deletions .github/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"subdir": "workflows"
}
},
"version": "20aac53fcb06d378b1c1101c7e4dc989466eb4ff",
"sum": "bo355Fm9Gm1TU13MjlXGXgrCXo4CPr7aEeTvgNFYAl8="
"version": "21f1189544e3976070cbdb6463f64c7a32dcc176",
"sum": "IPS1oGR8k7jk6J2snciTycWFgtISCwXSPhJ3A+nEGvY="
}
],
"legacyImports": false
Expand Down
2 changes: 2 additions & 0 deletions .github/release-workflows.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local imageJobs = {
'loki-canary-boringcrypto': build.image('loki-canary-boringcrypto', 'cmd/loki-canary-boringcrypto'),
promtail: build.image('promtail', 'clients/cmd/promtail'),
querytee: build.image('loki-query-tee', 'cmd/querytee', platform=['linux/amd64']),
'loki-docker-driver': build.dockerPlugin('grafana/loki-docker-driver', 'clients/cmd/docker-driver', platform=['linux/amd64', 'linux/arm64']),
};

local weeklyImageJobs = {
Expand All @@ -27,6 +28,7 @@ local weeklyImageJobs = {
'loki-canary-boringcrypto': build.weeklyImage('loki-canary-boringcrypto', 'cmd/loki-canary-boringcrypto'),
promtail: build.weeklyImage('promtail', 'clients/cmd/promtail'),
querytee: build.weeklyImage('loki-query-tee', 'cmd/querytee', platform=['linux/amd64']),
'loki-docker-driver': build.weeklyDockerPlugin('grafana/loki-docker-driver', 'clients/cmd/docker-driver', platform=['linux/amd64', 'linux/arm64']),
};

local buildImageVersion = std.extVar('BUILD_IMAGE_VERSION');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,78 @@
"platforms": "linux/amd64,linux/arm64,linux/arm"
"push": true
"tags": "${{ env.IMAGE_PREFIX }}/loki-canary-boringcrypto:${{ steps.weekly-version.outputs.version }}"
"loki-docker-driver":
"env":
"BUILD_TIMEOUT": 60
"IMAGE_PREFIX": "grafana"
"RELEASE_LIB_REF": "main"
"RELEASE_REPO": "grafana/loki"
"needs":
- "check"
"runs-on": "ubuntu-latest"
"steps":
- "name": "pull release library code"
"uses": "actions/checkout@v4"
"with":
"path": "lib"
"ref": "${{ env.RELEASE_LIB_REF }}"
"repository": "grafana/loki-release"
- "name": "pull code to release"
"uses": "actions/checkout@v4"
"with":
"path": "release"
"repository": "${{ env.RELEASE_REPO }}"
- "name": "setup node"
"uses": "actions/setup-node@v4"
"with":
"node-version": 20
- "name": "Set up QEMU"
"uses": "docker/setup-qemu-action@v3"
- "name": "set up docker buildx"
"uses": "docker/setup-buildx-action@v3"
- "name": "Login to DockerHub (from vault)"
"uses": "grafana/shared-workflows/actions/dockerhub-login@main"
- "id": "weekly-version"
"name": "Get weekly version"
"run": |
echo "version=$(./tools/image-tag)" >> $GITHUB_OUTPUT
platform="$(echo "${{ matrix.platform}}" | sed "s/\(.*\)\/\(.*\)/\1-\2/")"
echo "platform=${platform}" >> $GITHUB_OUTPUT
echo "platform_short=$(echo ${{ matrix.platform }} | cut -d / -f 2)" >> $GITHUB_OUTPUT
if [[ "${platform}" == "linux/arm64" ]]; then
echo "plugin_arch=-arm64" >> $GITHUB_OUTPUT
else
echo "plugin_arch=" >> $GITHUB_OUTPUT
fi
"working-directory": "release"
- "name": "Build and export"
"timeout-minutes": "${{ fromJSON(env.BUILD_TIMEOUT) }}"
"uses": "docker/build-push-action@v6"
"with":
"build-args": "IMAGE_TAG=${{ steps.weekly-version.outputs.version }},GOARCH=${{ steps.weekly-version.outputs.platform_short }}"
"context": "release"
"file": "release/clients/cmd/docker-driver/Dockerfile"
"outputs": "type=docker,dest=release/images/grafana/loki-docker-driver-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar"
"platforms": "${{ matrix.platform }}"
"push": false
"tags": "${{ env.IMAGE_PREFIX }}/grafana/loki-docker-driver:${{ steps.weekly-version.outputs.version }}"
- "env":
"BUILD_DIR": "release/clients/cmd/docker-driver"
"IMAGE_TAG": "${{ steps.weekly-version.outputs.version }}"
"name": "Package and push as Docker plugin"
"run": |
rm -rf "${{ env.BUILD_DIR }}/rootfs" || true
mkdir "${{ env.BUILD_DIR }}/rootfs"
tar -x -C "${{ env.BUILD_DIR }}/rootfs" -f "release/images/%s-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar"
docker plugin create "${{ env.IMAGE_TAG }}${{ steps.platform.outputs.plugin_arch }}" "${{ env.BUILD_DIR }}"
docker plugin push "${{ env.IMAGE_TAG }}${{ steps.platform.outputs.plugin_arch }}"
"working-directory": "release"
"strategy":
"matrix":
"platform":
- "linux/amd64"
- "linux/arm64"
"promtail":
"env":
"BUILD_TIMEOUT": 60
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/minor-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- "loki"
- "loki-canary"
- "loki-canary-boringcrypto"
- "loki-docker-driver"
- "promtail"
- "querytee"
runs-on: "ubuntu-latest"
Expand Down Expand Up @@ -598,6 +599,86 @@ jobs:
- "linux/amd64"
- "linux/arm64"
- "linux/arm"
loki-docker-driver:
needs:
- "version"
runs-on: "ubuntu-latest"
steps:
- name: "pull release library code"
uses: "actions/checkout@v4"
with:
path: "lib"
ref: "${{ env.RELEASE_LIB_REF }}"
repository: "grafana/loki-release"
- name: "pull code to release"
uses: "actions/checkout@v4"
with:
path: "release"
repository: "${{ env.RELEASE_REPO }}"
- name: "setup node"
uses: "actions/setup-node@v4"
with:
node-version: 20
- name: "auth gcs"
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCS_SERVICE_ACCOUNT_KEY }}"
- name: "Set up QEMU"
uses: "docker/setup-qemu-action@v3"
- name: "set up docker buildx"
uses: "docker/setup-buildx-action@v3"
- id: "platform"
name: "parse image platform"
run: |
mkdir -p images
platform="$(echo "${{ matrix.platform}}" | sed "s/\(.*\)\/\(.*\)/\1-\2/")"
echo "platform=${platform}" >> $GITHUB_OUTPUT
echo "platform_short=$(echo ${{ matrix.platform }} | cut -d / -f 2)" >> $GITHUB_OUTPUT
if [[ "${platform}" == "linux/arm64" ]]; then
echo "plugin_arch=-arm64" >> $GITHUB_OUTPUT
else
echo "plugin_arch=" >> $GITHUB_OUTPUT
fi
working-directory: "release"
- env:
IMAGE_TAG: "${{ needs.version.outputs.version }}"
if: "${{ fromJSON(needs.version.outputs.pr_created) }}"
name: "Build and export"
timeout-minutes: "${{ fromJSON(env.BUILD_TIMEOUT) }}"
uses: "docker/build-push-action@v6"
with:
build-args: "IMAGE_TAG=${{ needs.version.outputs.version }},GOARCH=${{ steps.platform.outputs.platform_short }}"
context: "release"
file: "release/clients/cmd/docker-driver/Dockerfile"
outputs: "type=docker,dest=release/images/grafana/loki-docker-driver-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar"
platforms: "${{ matrix.platform }}"
push: false
tags: "${{ env.IMAGE_PREFIX }}/grafana/loki-docker-driver:${{ needs.version.outputs.version }}-${{ steps.platform.outputs.platform_short }}"
- env:
BUILD_DIR: "release/clients/cmd/docker-driver"
IMAGE_TAG: "${{ needs.version.outputs.version }}"
if: "${{ fromJSON(needs.version.outputs.pr_created) }}"
name: "Package as Docker plugin"
run: |
rm -rf "${{ env.BUILD_DIR }}/rootfs" || true
mkdir "${{ env.BUILD_DIR }}/rootfs"
tar -x -C "${{ env.BUILD_DIR }}/rootfs" -f "release/images/%s-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar"
docker plugin create "${{ env.IMAGE_TAG }}${{ steps.platform.outputs.plugin_arch }}" "${{ env.BUILD_DIR }}"
working-directory: "release"
- if: "${{ fromJSON(needs.version.outputs.pr_created) }}"
name: "upload artifacts"
uses: "google-github-actions/upload-cloud-storage@v2"
with:
destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images"
path: "release/images/grafana/loki-docker-driver-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar"
process_gcloudignore: false
strategy:
fail-fast: true
matrix:
platform:
- "linux/amd64"
- "linux/arm64"
promtail:
needs:
- "version"
Expand Down
Loading

0 comments on commit 4088d64

Please sign in to comment.