-
Notifications
You must be signed in to change notification settings - Fork 879
Prebuild CLI E2E Docker image #16787
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7daa556
Prebuild CLI E2E Docker image
sebastienros 8cb7553
Refine CLI E2E image prebuild coverage
sebastienros c093519
Optimize CLI E2E image prebuild
sebastienros c138bb1
Preserve CLI E2E Dockerfile build args
sebastienros a1456c4
Prebuild polyglot CLI E2E images
sebastienros b7701bd
Isolate CLI E2E image helper tests
sebastienros 269f60f
Address CLI E2E image review feedback
sebastienros d5f29e8
Avoid external Buildx setup action
sebastienros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # Builds CLI E2E images shared across split test jobs. | ||
| # Podman uses a separate privileged runtime path and is intentionally left on its | ||
| # existing per-job Dockerfile path. | ||
| name: Build CLI E2E Docker Image | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| includePolyglotImages: | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
|
|
||
| env: | ||
| CLI_E2E_DOTNET_IMAGE_ARTIFACT: cli-e2e-dotnet-image | ||
| CLI_E2E_DOTNET_IMAGE_TAG: aspire-cli-e2e-dotnet:prebuilt | ||
| CLI_E2E_DOTNET_IMAGE_CACHE_SCOPE: cli-e2e-dotnet | ||
| CLI_E2E_POLYGLOT_IMAGE_ARTIFACT: cli-e2e-polyglot-image | ||
| CLI_E2E_POLYGLOT_IMAGE_TAG: aspire-cli-e2e-polyglot:prebuilt | ||
| CLI_E2E_POLYGLOT_JAVA_IMAGE_ARTIFACT: cli-e2e-polyglot-java-image | ||
| CLI_E2E_POLYGLOT_JAVA_IMAGE_TAG: aspire-cli-e2e-polyglot-java:prebuilt | ||
| CLI_E2E_POLYGLOT_BASE_IMAGE_TAG: aspire-e2e-polyglot-base:latest | ||
| CLI_E2E_POLYGLOT_BASE_IMAGE_CACHE_SCOPE: cli-e2e-polyglot-base | ||
| CLI_E2E_INCLUDE_POLYGLOT_IMAGES: ${{ inputs.includePolyglotImages }} | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build CLI E2E Docker image | ||
| runs-on: ${{ github.repository_owner == 'microsoft' && '8-core-ubuntu-latest' || 'ubuntu-latest' }} | ||
| timeout-minutes: 45 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Verify Docker is running | ||
| run: docker info | ||
|
sebastienros marked this conversation as resolved.
|
||
|
|
||
| - name: Export GitHub Actions cache runtime | ||
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
| with: | ||
| script: | | ||
| for (const name of ['ACTIONS_RUNTIME_TOKEN', 'ACTIONS_RUNTIME_URL', 'ACTIONS_CACHE_URL', 'ACTIONS_RESULTS_URL']) { | ||
| const value = process.env[name]; | ||
| if (value) { | ||
| core.setSecret(value); | ||
| core.exportVariable(name, value); | ||
| } | ||
| } | ||
|
|
||
| - name: Build CLI E2E Docker image | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| docker buildx create --name cli-e2e-builder --use | ||
| docker buildx inspect --bootstrap | ||
|
|
||
| build_image() { | ||
| local display_name="$1" | ||
| local dockerfile="$2" | ||
| local tag="$3" | ||
| local cache_scope="$4" | ||
| local mirror="$5" | ||
| local -a build_args=(--build-arg SKIP_SOURCE_BUILD=true) | ||
|
|
||
| if [[ -n "$mirror" ]]; then | ||
| echo "Building $display_name with Ubuntu apt mirror: $mirror" | ||
| build_args+=(--build-arg "UBUNTU_APT_MIRROR=$mirror") | ||
| else | ||
| echo "Building $display_name with the default Ubuntu apt sources" | ||
| fi | ||
|
|
||
| docker buildx build \ | ||
| --load \ | ||
| --cache-from "type=gha,scope=$cache_scope" \ | ||
|
sebastienros marked this conversation as resolved.
|
||
| --cache-to "type=gha,scope=$cache_scope,mode=max,ignore-error=true" \ | ||
| "${build_args[@]}" \ | ||
| -f "$dockerfile" \ | ||
| -t "$tag" \ | ||
| . | ||
| } | ||
|
|
||
| build_java_image() { | ||
| local mirror="$1" | ||
| local -a build_args=() | ||
|
|
||
| if [[ -n "$mirror" ]]; then | ||
| echo "Building Java polyglot image with Ubuntu apt mirror: $mirror" | ||
| build_args+=(--build-arg "UBUNTU_APT_MIRROR=$mirror") | ||
| else | ||
| echo "Building Java polyglot image with the default Ubuntu apt sources" | ||
| fi | ||
|
|
||
| DOCKER_BUILDKIT=1 docker build \ | ||
| "${build_args[@]}" \ | ||
| -f tests/Shared/Docker/Dockerfile.e2e-polyglot-java \ | ||
| -t "$CLI_E2E_POLYGLOT_JAVA_IMAGE_TAG" \ | ||
| . | ||
| } | ||
|
|
||
| build_with_mirror_retry() { | ||
| local display_name="$1" | ||
| local dockerfile="$2" | ||
| local tag="$3" | ||
| local cache_scope="$4" | ||
|
|
||
| if ! build_image "$display_name" "$dockerfile" "$tag" "$cache_scope" "http://azure.archive.ubuntu.com/ubuntu/"; then | ||
| echo "$display_name build failed with the Azure Ubuntu apt mirror; retrying with default Ubuntu apt sources" | ||
| build_image "$display_name" "$dockerfile" "$tag" "$cache_scope" "" | ||
| fi | ||
| } | ||
|
|
||
| build_with_mirror_retry ".NET image" "tests/Shared/Docker/Dockerfile.e2e" "$CLI_E2E_DOTNET_IMAGE_TAG" "$CLI_E2E_DOTNET_IMAGE_CACHE_SCOPE" | ||
|
|
||
| if [[ "$CLI_E2E_INCLUDE_POLYGLOT_IMAGES" == "true" ]]; then | ||
| build_with_mirror_retry "polyglot base image" "tests/Shared/Docker/Dockerfile.e2e-polyglot-base" "$CLI_E2E_POLYGLOT_BASE_IMAGE_TAG" "$CLI_E2E_POLYGLOT_BASE_IMAGE_CACHE_SCOPE" | ||
| docker tag "$CLI_E2E_POLYGLOT_BASE_IMAGE_TAG" "$CLI_E2E_POLYGLOT_IMAGE_TAG" | ||
|
|
||
| if ! build_java_image "http://azure.archive.ubuntu.com/ubuntu/"; then | ||
| echo "Java polyglot image build failed with the Azure Ubuntu apt mirror; retrying with default Ubuntu apt sources" | ||
| build_java_image "" | ||
| fi | ||
| fi | ||
|
|
||
| mkdir -p artifacts/cli-e2e-image | ||
| docker save "$CLI_E2E_DOTNET_IMAGE_TAG" | gzip > artifacts/cli-e2e-image/aspire-cli-e2e-dotnet.tar.gz | ||
| if [[ "$CLI_E2E_INCLUDE_POLYGLOT_IMAGES" == "true" ]]; then | ||
| docker save "$CLI_E2E_POLYGLOT_IMAGE_TAG" | gzip > artifacts/cli-e2e-image/aspire-cli-e2e-polyglot.tar.gz | ||
| docker save "$CLI_E2E_POLYGLOT_JAVA_IMAGE_TAG" | gzip > artifacts/cli-e2e-image/aspire-cli-e2e-polyglot-java.tar.gz | ||
| fi | ||
|
|
||
| - name: Upload CLI E2E .NET Docker image | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: ${{ env.CLI_E2E_DOTNET_IMAGE_ARTIFACT }} | ||
| path: artifacts/cli-e2e-image/aspire-cli-e2e-dotnet.tar.gz | ||
| retention-days: 1 | ||
|
|
||
| - name: Upload CLI E2E polyglot Docker image | ||
| if: ${{ inputs.includePolyglotImages }} | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: ${{ env.CLI_E2E_POLYGLOT_IMAGE_ARTIFACT }} | ||
| path: artifacts/cli-e2e-image/aspire-cli-e2e-polyglot.tar.gz | ||
| retention-days: 1 | ||
|
|
||
| - name: Upload CLI E2E Java Docker image | ||
| if: ${{ inputs.includePolyglotImages }} | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: ${{ env.CLI_E2E_POLYGLOT_JAVA_IMAGE_ARTIFACT }} | ||
| path: artifacts/cli-e2e-image/aspire-cli-e2e-polyglot-java.tar.gz | ||
| retention-days: 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.