From 82e03978b89938219958032efb1448cc76baa181 Mon Sep 17 00:00:00 2001 From: Saumit Date: Sat, 27 Sep 2025 02:14:26 +0530 Subject: Initial snapshot - OpenTelemetry demo 2.1.3 -f --- .github/workflows/component-build-images.yml | 219 +++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 .github/workflows/component-build-images.yml (limited to '.github/workflows/component-build-images.yml') diff --git a/.github/workflows/component-build-images.yml b/.github/workflows/component-build-images.yml new file mode 100644 index 0000000..a4c9544 --- /dev/null +++ b/.github/workflows/component-build-images.yml @@ -0,0 +1,219 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +on: + workflow_call: + inputs: + push: + description: Should the images be pushed + default: false + required: false + type: boolean + version: + description: The version used when tagging the image + default: 'dev' + required: false + type: string + dockerhub_repo: + description: Docker Hub repository + default: 'otel/demo' + required: false + type: string + ghcr_repo: + description: GHCR repository + default: 'ghcr.io/open-telemetry/demo' + required: false + type: string + +permissions: + contents: read + +jobs: + protobufcheck: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + - name: Generate + run: make clean docker-generate-protobuf + - name: Check Clean Work Tree + run: make check-clean-work-tree + + build_and_push_images: + runs-on: ubuntu-latest + needs: protobufcheck + + permissions: + contents: read + packages: write + + env: + RELEASE_VERSION: "${{ github.event.release.tag_name }}" + + strategy: + fail-fast: false + matrix: + file_tag: + - file: ./src/accounting/Dockerfile + tag_suffix: accounting + context: ./ + setup-qemu: true + - file: ./src/ad/Dockerfile + tag_suffix: ad + context: ./ + setup-qemu: true + - file: ./src/cart/src/Dockerfile + tag_suffix: cart + context: ./ + setup-qemu: false + - file: ./src/checkout/Dockerfile + tag_suffix: checkout + context: ./ + setup-qemu: true + - file: ./src/currency/Dockerfile + tag_suffix: currency + context: ./ + setup-qemu: true + - file: ./src/email/Dockerfile + tag_suffix: email + context: ./ + setup-qemu: true + - file: ./src/flagd-ui/Dockerfile + tag_suffix: flagd-ui + context: ./ + setup-qemu: true + - file: ./src/fraud-detection/Dockerfile + tag_suffix: fraud-detection + context: ./ + setup-qemu: true + - file: ./src/frontend/Dockerfile + tag_suffix: frontend + context: ./ + setup-qemu: true + - file: ./src/frontend-proxy/Dockerfile + tag_suffix: frontend-proxy + context: ./ + setup-qemu: true + - file: ./src/frontend/Dockerfile.cypress + tag_suffix: frontend-tests + context: ./ + setup-qemu: true + - file: ./src/image-provider/Dockerfile + tag_suffix: image-provider + context: ./ + setup-qemu: true + - file: ./src/kafka/Dockerfile + tag_suffix: kafka + context: ./ + setup-qemu: true + - file: ./src/load-generator/Dockerfile + tag_suffix: load-generator + context: ./ + setup-qemu: true + - file: ./src/opensearch/Dockerfile + tag_suffix: opensearch + context: ./ + setup-qemu: true + - file: ./src/payment/Dockerfile + tag_suffix: payment + context: ./ + setup-qemu: true + - file: ./src/postgres/Dockerfile + tag_suffix: postgresql + context: ./ + setup-qemu: true + - file: ./src/product-catalog/Dockerfile + tag_suffix: product-catalog + context: ./ + setup-qemu: true + - file: ./src/quote/Dockerfile + tag_suffix: quote + context: ./ + setup-qemu: true + - file: ./src/recommendation/Dockerfile + tag_suffix: recommendation + context: ./ + setup-qemu: true + - file: ./src/shipping/Dockerfile + tag_suffix: shipping + context: ./ + setup-qemu: true + - file: ./test/tracetesting/Dockerfile + tag_suffix: traceBasedTests + context: ./ + setup-qemu: true + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Load environment variables from .env file + run: | + if [ -f .env ]; then + # Filter out comments and empty lines, then add each variable to $GITHUB_ENV + grep -vE '^\s*#|^\s*$' .env | while read -r line; do + echo "$line" >> $GITHUB_ENV + done + else + echo ".env file not found!" + exit 1 + fi + - name: Check for changes and set push options + id: check_changes + run: | + DOCKERFILE_DIR=$(dirname ${{ matrix.file_tag.file }}) + FILES_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- $DOCKERFILE_DIR) + FORCE_PUSH=${{ inputs.push }} + if [ "$FORCE_PUSH" = true ]; then + echo "Force push is enabled, proceeding with build." + echo "skip=false" >> "$GITHUB_OUTPUT" + elif [ -z "$FILES_CHANGED" ]; then + echo "No changes in ${{ matrix.file_tag.context }}, skipping build." + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "Changes detected in ${{ matrix.file_tag.context }}, proceeding with build." + echo "skip=false" >> "$GITHUB_OUTPUT" + fi + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + if: ${{ inputs.push }} + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + if: ${{ inputs.push }} + - name: Set up QEMU + if: ${{ matrix.file_tag.setup-qemu }} + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:master + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-config-inline: | + [worker.oci] + max-parallelism = 2 + - name: Matrix Build and push demo images + if: steps.check_changes.outputs.skip == 'false' + uses: docker/build-push-action@v6.18.0 + with: + context: ${{ matrix.file_tag.context }} + file: ${{ matrix.file_tag.file }} + platforms: linux/amd64,linux/arm64 + push: ${{ inputs.push }} + build-args: | + OTEL_JAVA_AGENT_VERSION=${{ env.OTEL_JAVA_AGENT_VERSION }} + OPENTELEMETRY_CPP_VERSION=${{ env.OPENTELEMETRY_CPP_VERSION }} + TRACETEST_IMAGE_VERSION=${{ env.TRACETEST_IMAGE_VERSION }} + tags: | + ${{ inputs.dockerhub_repo }}:${{ inputs.version }}-${{matrix.file_tag.tag_suffix }} + ${{ inputs.dockerhub_repo }}:latest-${{matrix.file_tag.tag_suffix }} + ${{ inputs.ghcr_repo }}:${{ inputs.version }}-${{ matrix.file_tag.tag_suffix }} + ${{ inputs.ghcr_repo }}:latest-${{ matrix.file_tag.tag_suffix }} + cache-from: type=gha + cache-to: type=gha -- cgit v1.2.3