generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 155
Android Docker Image Build #2830
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
2 commits
Select commit
Hold shift + click to select a range
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,27 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
|
||
| name: 'configure-aws-credentials' | ||
| description: 'A helper for configure AWS credentials for AWS-LC GitHub actions' | ||
| inputs: | ||
| roleName: | ||
| description: "The target IAM role to assume using the OIDC role credentials" | ||
| required: true | ||
| default: 'AwsLcGitHubActionStandardRole' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Query Environment | ||
| id: env | ||
| shell: bash | ||
| run: | | ||
| echo aws_account_id=${AWS_ACCOUNT_ID} >> "$GITHUB_OUTPUT" | ||
| - name: Retrieve OIDC Role Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| role-to-assume: arn:aws:iam::${{ steps.env.outputs.aws_account_id }}:role/AwsLcGitHubActionsOidcRole | ||
| - name: Retrieve GitHub Actions Role Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| role-to-assume: arn:aws:iam::${{ steps.env.outputs.aws_account_id }}:role/${{ inputs.roleName }} | ||
| role-chaining: true |
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,94 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
|
||
| FROM public.ecr.aws/ubuntu/ubuntu:24.04 AS base | ||
|
|
||
| SHELL ["/bin/bash", "-c"] | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
|
|
||
| ENV ANDROID_SDK_URL=commandlinetools-linux-13114758_latest | ||
| ENV ANDROID_HOME=/opt/sdk | ||
| ENV ANDROID_SDK_ROOT=/opt/sdk | ||
| ENV GRADLE_VERSION=gradle-7.6.4 | ||
| ENV GOROOT=/usr/local/go | ||
| ENV PATH="$GOROOT/bin:/opt/sdk/cmdline-tools/latest/bin:$PATH" | ||
| # ------------------------------------------------------ | ||
| # --- Android SDK | ||
|
|
||
| RUN <<EOF | ||
| set -ex | ||
| apt-get update -y | ||
| apt-get -y --no-install-recommends upgrade | ||
| apt-get -y --no-install-recommends install \ | ||
| git \ | ||
| libunwind-dev \ | ||
| openjdk-17-jdk \ | ||
| perl \ | ||
| python3.12 \ | ||
| python3.12-venv \ | ||
| python3-pip \ | ||
| unzip \ | ||
| wget | ||
| EOF | ||
|
|
||
| # Setup Android SDK | ||
| RUN <<EOF | ||
| # Set Java 17 as default | ||
| export JAVA17_ALT=$(update-alternatives --list java | grep java-17 | head -1) | ||
| update-alternatives --set java $JAVA17_ALT | ||
|
|
||
| # Set Java 17 for SDK manager compatibility | ||
| export JAVA_HOME=$(find /usr/lib/jvm -name "*java-17*" -type d | head -1) | ||
| export PATH=$JAVA_HOME/bin:$PATH | ||
|
|
||
| # install android-sdk from url source | ||
| mkdir /opt/sdk | ||
| mkdir /opt/sdk/cmdline-tools | ||
| mkdir /opt/cmdline-tools-tmp | ||
| cd /opt/cmdline-tools-tmp | ||
| wget -q https://dl.google.com/android/repository/${ANDROID_SDK_URL}.zip | ||
| unzip ${ANDROID_SDK_URL}.zip | ||
|
|
||
| # move to its final location and export path | ||
| mv ./cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest | ||
| cd $ANDROID_HOME/cmdline-tools/latest/bin | ||
| ./sdkmanager --update | ||
| yes | ./sdkmanager --licenses | ||
|
|
||
| # Preinstall AWSLCAndroidTestRunner android dependencies, so they don't need to be | ||
| # rebuilt for each new gradle build run. | ||
| ./sdkmanager "ndk;28.2.13676358" \ | ||
| "build-tools;33.0.3" \ | ||
| "cmake;3.18.1" \ | ||
| "platforms;android-30" | ||
|
|
||
| cd /opt | ||
| wget -q https://services.gradle.org/distributions/${GRADLE_VERSION}-all.zip | ||
| rm -rf /opt/cmdline-tools-tmp | ||
| rm -rf /tmp/* | ||
| EOF | ||
|
|
||
| # Preinstall gradle dependencies, so they don't need to be redownloaded in the CI. | ||
| COPY . /tmp/triggerGradleDownloads/ | ||
|
|
||
| RUN <<EOF | ||
| cd /tmp/triggerGradleDownloads | ||
| echo "JAVA_HOME=$JAVA_HOME" | ||
| java -version | ||
| echo "PATH=$PATH" | ||
| ./gradlew --no-daemon --refresh-dependencies androidDependencies lint | ||
| EOF | ||
|
|
||
| # Install Go | ||
| ENV GOENV_ROOT="/.goenv" | ||
| ENV PATH="${GOENV_ROOT}/shims:${GOENV_ROOT}/bin:/go/bin:$PATH" | ||
|
|
||
| COPY --from=scripts setup-go-compiler.sh /tmp | ||
| RUN <<EOF | ||
| setup_script="/tmp/setup-go-compiler.sh" | ||
| ${setup_script} | ||
| EOF | ||
|
|
||
| RUN rm -rf /tmp/* | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,102 @@ | ||
| name: image-build-android | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| concurrency_prefix: | ||
| default: image-build-android | ||
| required: false | ||
| type: string | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - .github/docker_images/aws-lc/android/Dockerfile | ||
| - .github/docker_images/scripts/** | ||
| pull_request_target: | ||
| branches: [main] | ||
| paths: | ||
| - .github/docker_images/aws-lc/android/Dockerfile | ||
| - .github/docker_images/scripts/** | ||
| concurrency: | ||
| group: ${{ inputs.concurrency_prefix || github.workflow }}-${{ github.ref_name }} | ||
| cancel-in-progress: true | ||
| env: | ||
| GOPROXY: https://proxy.golang.org,direct | ||
| DOCKER_BUILD_RECORD_UPLOAD: false | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: | ||
| codebuild-aws-lc-ci-github-actions-${{ github.run_id }}-${{ github.run_attempt }} | ||
| image:linux-5.0 | ||
| instance-size:small | ||
| outputs: | ||
| android: ${{ steps.images.outputs.latest }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Query Environment | ||
| id: env | ||
| run: | | ||
| echo staging_url=${ECR_STAGING_REPO} >> "$GITHUB_OUTPUT" | ||
| - name: Retrieve Credentials | ||
| uses: ./.github/actions/configure-aws-credentials | ||
| with: | ||
| roleName: AwsLcGitHubActionDockerImageBuildRole | ||
| - name: Login to Amazon ECR | ||
| id: login-ecr | ||
| uses: aws-actions/amazon-ecr-login@v2 | ||
| - name: Generate Staging Image Names | ||
| id: images | ||
| run: | | ||
| echo latest=${{ steps.env.outputs.staging_url }}:$(uuidgen) >> "$GITHUB_OUTPUT" | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - uses: docker/build-push-action@v6 | ||
| with: | ||
| file: ./.github/docker_images/aws-lc/android/Dockerfile | ||
| context: ./.github/docker_images/aws-lc/android | ||
| build-contexts: | | ||
| scripts=./.github/docker_images/scripts | ||
| tags: ${{ steps.images.outputs.latest }} | ||
| push: true | ||
| - uses: ./.github/actions/codebuild-docker-run | ||
| name: Validate Container | ||
| with: | ||
| image: ${{ steps.images.outputs.latest }} | ||
| run: | | ||
| ./.github/docker_images/scripts/verify-go-version.sh 1.25 | ||
| push: | ||
| if: ${{ github.event_name != 'pull_request' }} | ||
| runs-on: | ||
| codebuild-aws-lc-ci-github-actions-${{ github.run_id }}-${{ github.run_attempt }} | ||
| image:linux-5.0 | ||
| instance-size:small | ||
| needs: | ||
| - build | ||
| outputs: | ||
| android: ${{ steps.images.outputs.android }} | ||
| steps: | ||
| - name: Login to Amazon ECR | ||
| id: login-ecr | ||
| uses: aws-actions/amazon-ecr-login@v2 | ||
| - name: Get ECR Registry & Repository Details | ||
| id: ecr | ||
| run: | | ||
| echo registry_url=${ECR_REGISTRY_URL} >> "$GITHUB_OUTPUT" | ||
| - name: Generate Staging Image Names | ||
| id: images | ||
| run: | | ||
| echo latest=${{ steps.ecr.outputs.registry_url }}/aws-lc/android:latest >> "$GITHUB_OUTPUT" | ||
| - name: Pull Images From Staging | ||
| run: | | ||
| docker pull ${{ needs.build.outputs.android }} | ||
| - name: Tag Images | ||
| run: | | ||
| docker tag ${{ needs.build.outputs.android }} ${{ steps.images.outputs.latest }} | ||
| - name: Push Images | ||
| run: | | ||
| docker push ${{ steps.images.outputs.latest }} |
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
70 changes: 0 additions & 70 deletions
70
tests/ci/docker_images/linux-x86/ubuntu-24.04_android/Dockerfile
This file was deleted.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't immediately obvious to me how we selected Java 17. It might be worth linking to the source of this info. I see it here: https://developer.android.com/build/jdks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't have the context on this myself. Our Android build is in some dire need of some TLC. It's a bit lost due to how the diff is shown, but this was just a straight move of this file, and I converted it to use heredoc syntax. Otherwise content is the same as before with the addition of the adjustment to use the new Go install script like the other images we build. I also say the Android build needs some TLC as our Gradle tends to trend out of date, requiring us to use an older JDK, and then we still use old SDKs etc. Tends to become a problem when we go to debug the occasional failure and realize how much it has drifted in terms of Android development environment changes.