diff --git a/.github/jsonnetfile.json b/.github/jsonnetfile.json index 58c6d34c67c48..731d3c3c82974 100644 --- a/.github/jsonnetfile.json +++ b/.github/jsonnetfile.json @@ -8,7 +8,7 @@ "subdir": "workflows" } }, - "version": "20aac53fcb06d378b1c1101c7e4dc989466eb4ff" + "version": "21f1189544e3976070cbdb6463f64c7a32dcc176" } ], "legacyImports": true diff --git a/.github/jsonnetfile.lock.json b/.github/jsonnetfile.lock.json index 5d356b0b4fb0b..d11f133725822 100644 --- a/.github/jsonnetfile.lock.json +++ b/.github/jsonnetfile.lock.json @@ -8,8 +8,8 @@ "subdir": "workflows" } }, - "version": "20aac53fcb06d378b1c1101c7e4dc989466eb4ff", - "sum": "bo355Fm9Gm1TU13MjlXGXgrCXo4CPr7aEeTvgNFYAl8=" + "version": "21f1189544e3976070cbdb6463f64c7a32dcc176", + "sum": "IPS1oGR8k7jk6J2snciTycWFgtISCwXSPhJ3A+nEGvY=" } ], "legacyImports": false diff --git a/.github/release-workflows.jsonnet b/.github/release-workflows.jsonnet index 6c16af50ad74c..080dcae2d39c4 100644 --- a/.github/release-workflows.jsonnet +++ b/.github/release-workflows.jsonnet @@ -15,18 +15,14 @@ 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 = { loki: build.weeklyImage('loki', 'cmd/loki'), - fluentd: build.weeklyImage('fluent-plugin-loki', 'clients/cmd/fluentd', platform=['linux/amd64']), - 'fluent-bit': build.weeklyImage('fluent-bit-plugin-loki', 'clients/cmd/fluent-bit', platform=['linux/amd64']), - logstash: build.weeklyImage('logstash-output-loki', 'clients/cmd/logstash', platform=['linux/amd64']), - logcli: build.weeklyImage('logcli', 'cmd/logcli'), 'loki-canary': build.weeklyImage('loki-canary', 'cmd/loki-canary'), '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']), }; local buildImageVersion = std.extVar('BUILD_IMAGE_VERSION'); diff --git a/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet b/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet index 7343c7d72963d..72a47e901e890 100644 --- a/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet +++ b/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet @@ -105,6 +105,152 @@ local releaseLibStep = common.releaseLibStep; }), ]), + dockerPlugin: function( + name, + path, + dockerfile='Dockerfile', + context='release', + platform=[ + 'linux/amd64', + 'linux/arm64', + 'linux/arm', + ] + ) + job.new() + + job.withStrategy({ + 'fail-fast': true, + matrix: { + platform: platform, + }, + }) + + job.withSteps([ + common.fetchReleaseLib, + common.fetchReleaseRepo, + common.setupNode, + common.googleAuth, + + step.new('Set up QEMU', 'docker/setup-qemu-action@v3'), + step.new('set up docker buildx', 'docker/setup-buildx-action@v3'), + + releaseStep('parse image platform') + + step.withId('platform') + + step.withRun(||| + 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 + |||), + + step.new('Build and export', 'docker/build-push-action@v6') + + step.withTimeoutMinutes('${{ fromJSON(env.BUILD_TIMEOUT) }}') + + step.withIf('${{ fromJSON(needs.version.outputs.pr_created) }}') + + step.withEnv({ + IMAGE_TAG: '${{ needs.version.outputs.version }}', + }) + + step.with({ + context: context, + file: 'release/%s/%s' % [path, dockerfile], + platforms: '${{ matrix.platform }}', + push: false, + tags: '${{ env.IMAGE_PREFIX }}/%s:${{ needs.version.outputs.version }}-${{ steps.platform.outputs.platform_short }}' % [name], + outputs: 'type=docker,dest=release/images/%s-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar' % name, + 'build-args': 'IMAGE_TAG=${{ needs.version.outputs.version }},GOARCH=${{ steps.platform.outputs.platform_short }}', + }), + + releaseStep('Package as Docker plugin') + + step.withIf('${{ fromJSON(needs.version.outputs.pr_created) }}') + + step.withEnv({ + IMAGE_TAG: '${{ needs.version.outputs.version }}', + BUILD_DIR: 'release/%s' % [path], + }) + + step.withRun(||| + 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 }}" + |||), + + step.new('upload artifacts', 'google-github-actions/upload-cloud-storage@v2') + + step.withIf('${{ fromJSON(needs.version.outputs.pr_created) }}') + + step.with({ + path: 'release/images/%s-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar' % name, + destination: '${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images', //TODO: make bucket configurable + process_gcloudignore: false, + }), + ]), + + weeklyDockerPlugin: function( + name, + path, + dockerfile='Dockerfile', + context='release', + platform=[ + 'linux/amd64', + 'linux/arm64', + 'linux/arm', + ] + ) + job.new() + + job.withStrategy({ + matrix: { + platform: platform, + }, + }) + + job.withSteps([ + common.fetchReleaseLib, + common.fetchReleaseRepo, + common.setupNode, + + step.new('Set up QEMU', 'docker/setup-qemu-action@v3'), + step.new('set up docker buildx', 'docker/setup-buildx-action@v3'), + step.new('Login to DockerHub (from vault)', 'grafana/shared-workflows/actions/dockerhub-login@main'), + + releaseStep('Get weekly version') + + step.withId('weekly-version') + + step.withRun(||| + 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 + |||), + + step.new('Build and export', 'docker/build-push-action@v6') + + step.withTimeoutMinutes('${{ fromJSON(env.BUILD_TIMEOUT) }}') + + step.with({ + context: context, + file: 'release/%s/%s' % [path, dockerfile], + platforms: '${{ matrix.platform }}', + push: false, + tags: '${{ env.IMAGE_PREFIX }}/%s:${{ steps.weekly-version.outputs.version }}' % [name], + outputs: 'type=docker,dest=release/images/%s-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar' % name, + 'build-args': 'IMAGE_TAG=${{ steps.weekly-version.outputs.version }},GOARCH=${{ steps.weekly-version.outputs.platform_short }}', + }), + + releaseStep('Package and push as Docker plugin') + + step.withEnv({ + IMAGE_TAG: '${{ steps.weekly-version.outputs.version }}', + BUILD_DIR: 'release/%s' % [path], + }) + + step.withRun(||| + 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 }}" + |||), + ]), version: job.new() diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 40801f19317d3..55bbd64d6c3f9 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -7,190 +7,6 @@ "release_lib_ref": "main" "skip_validation": false "use_github_app_token": true - "fluent-bit": - "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 - "working-directory": "release" - - "name": "Build and push" - "timeout-minutes": "${{ fromJSON(env.BUILD_TIMEOUT) }}" - "uses": "docker/build-push-action@v6" - "with": - "build-args": "IMAGE_TAG=${{ steps.weekly-version.outputs.version }}" - "context": "release" - "file": "release/clients/cmd/fluent-bit/Dockerfile" - "platforms": "linux/amd64" - "push": true - "tags": "${{ env.IMAGE_PREFIX }}/fluent-bit-plugin-loki:${{ steps.weekly-version.outputs.version }}" - "fluentd": - "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 - "working-directory": "release" - - "name": "Build and push" - "timeout-minutes": "${{ fromJSON(env.BUILD_TIMEOUT) }}" - "uses": "docker/build-push-action@v6" - "with": - "build-args": "IMAGE_TAG=${{ steps.weekly-version.outputs.version }}" - "context": "release" - "file": "release/clients/cmd/fluentd/Dockerfile" - "platforms": "linux/amd64" - "push": true - "tags": "${{ env.IMAGE_PREFIX }}/fluent-plugin-loki:${{ steps.weekly-version.outputs.version }}" - "logcli": - "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 - "working-directory": "release" - - "name": "Build and push" - "timeout-minutes": "${{ fromJSON(env.BUILD_TIMEOUT) }}" - "uses": "docker/build-push-action@v6" - "with": - "build-args": "IMAGE_TAG=${{ steps.weekly-version.outputs.version }}" - "context": "release" - "file": "release/cmd/logcli/Dockerfile" - "platforms": "linux/amd64,linux/arm64,linux/arm" - "push": true - "tags": "${{ env.IMAGE_PREFIX }}/logcli:${{ steps.weekly-version.outputs.version }}" - "logstash": - "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 - "working-directory": "release" - - "name": "Build and push" - "timeout-minutes": "${{ fromJSON(env.BUILD_TIMEOUT) }}" - "uses": "docker/build-push-action@v6" - "with": - "build-args": "IMAGE_TAG=${{ steps.weekly-version.outputs.version }}" - "context": "release" - "file": "release/clients/cmd/logstash/Dockerfile" - "platforms": "linux/amd64" - "push": true - "tags": "${{ env.IMAGE_PREFIX }}/logstash-output-loki:${{ steps.weekly-version.outputs.version }}" "loki": "env": "BUILD_TIMEOUT": 60 @@ -375,52 +191,6 @@ "platforms": "linux/amd64,linux/arm64,linux/arm" "push": true "tags": "${{ env.IMAGE_PREFIX }}/promtail:${{ steps.weekly-version.outputs.version }}" - "querytee": - "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 - "working-directory": "release" - - "name": "Build and push" - "timeout-minutes": "${{ fromJSON(env.BUILD_TIMEOUT) }}" - "uses": "docker/build-push-action@v6" - "with": - "build-args": "IMAGE_TAG=${{ steps.weekly-version.outputs.version }}" - "context": "release" - "file": "release/cmd/querytee/Dockerfile" - "platforms": "linux/amd64" - "push": true - "tags": "${{ env.IMAGE_PREFIX }}/loki-query-tee:${{ steps.weekly-version.outputs.version }}" "name": "publish images" "on": "push": diff --git a/.github/workflows/minor-release-pr.yml b/.github/workflows/minor-release-pr.yml index 807e52afab253..0db833dec9a2f 100644 --- a/.github/workflows/minor-release-pr.yml +++ b/.github/workflows/minor-release-pr.yml @@ -31,6 +31,7 @@ jobs: - "loki" - "loki-canary" - "loki-canary-boringcrypto" + - "loki-docker-driver" - "promtail" - "querytee" runs-on: "ubuntu-latest" @@ -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" diff --git a/.github/workflows/patch-release-pr.yml b/.github/workflows/patch-release-pr.yml index 840f1d1d3f49e..f1b904d22f407 100644 --- a/.github/workflows/patch-release-pr.yml +++ b/.github/workflows/patch-release-pr.yml @@ -31,6 +31,7 @@ jobs: - "loki" - "loki-canary" - "loki-canary-boringcrypto" + - "loki-docker-driver" - "promtail" - "querytee" runs-on: "ubuntu-latest" @@ -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"