-
Notifications
You must be signed in to change notification settings - Fork 121
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
Pre-pull aws crt Docker images. #102
Merged
Merged
Changes from 3 commits
Commits
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 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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
# Prerequistes | ||
EC2 x86-64 Ubuntu 19.10 host with Docker server installed (Docker instructions | ||
taken from | ||
[Docker docs](https://docs.docker.com/install/linux/docker-ce/ubuntu/)): | ||
``` | ||
$ sudo apt-get update | ||
$ sudo apt-get install -y awscli apt-transport-https ca-certificates curl gnupg-agent software-properties-common | ||
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
$ sudo apt-get update | ||
$ sudo apt-get install -y docker-ce | ||
$ sudo usermod -aG docker ${USER} | ||
# Log in and out | ||
``` | ||
|
||
Build images locally with `build_images.sh`, to push to the main repository run | ||
`push_images.sh`. To push to your own repository pass in a complete ECS url | ||
`push_images.sh ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/${REPOSITORY}`. | ||
* [Create GitHub Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) | ||
* Note: This token ONLY needs ['read:packages' permission](https://docs.github.com/en/packages/learn-github-packages/about-github-packages#authenticating-to-github-packages), and should be deleted from GitHub account after docker image build. | ||
* This token is needed when pulling images from 'docker.pkg.github.com'. | ||
|
||
# Usage | ||
|
||
## Docker image build and pull. | ||
Build images locally with `build_images.sh`, which pulls Docker images from Docker hub. | ||
Pull images from 'docker.pkg.github.com' with `pull_github_pkg.sh`. | ||
|
||
## Docker image push. | ||
To push to the ECR repository of default AWS account, run `push_images.sh`. | ||
To push to the ECR repository pass in a complete ECS url `push_images.sh ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/${REPOSITORY}`. | ||
74 changes: 74 additions & 0 deletions
74
tests/ci/docker_images/linux-x86/aws-crt/aws-crt-common.sh
This file contains 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,74 @@ | ||
#!/bin/bash -ex | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
parent_dir="$(dirname -- "$(realpath -- "$file_name")")" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. Move this source to upper dir.
|
||
# shellcheck source=../common.sh | ||
source "${parent_dir}/common.sh" | ||
|
||
################################# | ||
# Set up environment variables # | ||
################################# | ||
|
||
if [[ -z "${ECS_REPO+x}" || -z "${ECS_REPO}" ]]; then | ||
export ECS_REPO="620771051181.dkr.ecr.us-west-2.amazonaws.com/aws-lc-docker-images-linux-x86" | ||
fi | ||
|
||
if [[ -z "${GITHUB_REPO_OWNER+x}" || -z "${GITHUB_REPO_OWNER}" ]]; then | ||
# The owner of the GitHub personal access token. Required when login 'docker.pkg.github.com'. | ||
export GITHUB_REPO_OWNER='awslabs' | ||
fi | ||
|
||
# Environment variables used by AWS-C-CAL | ||
# CI of AWS-C-CAL https://github.com/awslabs/aws-c-cal/blob/905b0fd0ff2ca0d86c7e49b8ef4b636bac4600ea/.github/workflows/ci.yml | ||
# The CI uses Docker images provided by https://github.com/awslabs/aws-crt-builder | ||
BUILDER_VERSION='v0.7.2' | ||
BASE_AWS_CRT_DOCKER_IMG_PREFIX='docker.pkg.github.com/awslabs/aws-crt-builder' | ||
AWS_CRT_MANY_LINUX_SUFFIXES=('aws-crt-manylinux1-x64' 'aws-crt-manylinux1-x86' 'aws-crt-manylinux2014-x64' 'aws-crt-manylinux2014-x86') | ||
AWS_CRT_AL2_X64_SUFFIX='aws-crt-al2-x64' | ||
AWS_CRT_AL2_X64="${BASE_AWS_CRT_DOCKER_IMG_PREFIX}/${AWS_CRT_AL2_X64_SUFFIX}:${BUILDER_VERSION}" | ||
AWS_CRT_UBUNTU_16_X64_SUFFIX='aws-crt-ubuntu-16-x64' | ||
AWS_CRT_UBUNTU_16_X64="${BASE_AWS_CRT_DOCKER_IMG_PREFIX}/${AWS_CRT_UBUNTU_16_X64_SUFFIX}:${BUILDER_VERSION}" | ||
|
||
#################################### | ||
# Migrate Docker images to AWS ECR # | ||
#################################### | ||
|
||
function login_github_docker_pkg() { | ||
if [[ -z "${GITHUB_READ_PKG_ACCESS_TOKEN+x}" || -z "${GITHUB_READ_PKG_ACCESS_TOKEN}" ]]; then | ||
# GITHUB_READ_PKG_ACCESS_TOKEN is required when pulling images from 'docker.pkg.github.com'. | ||
# When creating GitHub personal access token, make sure ONLY "read:packages" is granted. | ||
# https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token | ||
# https://docs.github.com/en/packages/learn-github-packages/about-github-packages#authenticating-to-github-packages | ||
echo "GITHUB_READ_PKG_ACCESS_TOKEN is not defined or empty." | ||
exit 1 | ||
fi | ||
echo "${GITHUB_READ_PKG_ACCESS_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_REPO_OWNER}" --password-stdin | ||
} | ||
|
||
function pull_aws_crt_docker_img() { | ||
# Pull aws-crt-manylinux*:v0.7.2 | ||
for i in "${AWS_CRT_MANY_LINUX_SUFFIXES[@]}"; do | ||
docker_img="${BASE_AWS_CRT_DOCKER_IMG_PREFIX}/${i}:${BUILDER_VERSION}" | ||
docker pull "${docker_img}" | ||
done | ||
# Pull aws-crt-al2-x64:v0.7.2 | ||
docker pull "${AWS_CRT_AL2_X64}" | ||
# Pull aws-crt-ubuntu-16-x64:v0.7.2 | ||
docker pull "${AWS_CRT_UBUNTU_16_X64}" | ||
} | ||
|
||
function push_aws_crt_docker_img() { | ||
# Push aws-crt-manylinux*_v0.7.2 | ||
for i in "${AWS_CRT_MANY_LINUX_SUFFIXES[@]}"; do | ||
source_docker_img="${BASE_AWS_CRT_DOCKER_IMG_PREFIX}/${i}:${BUILDER_VERSION}" | ||
target_docker_img="${ECS_REPO}:${i}_${BUILDER_VERSION}" | ||
tag_and_push_img "${source_docker_img}" "${target_docker_img}" | ||
done | ||
# Push aws-crt-al2-x64_v0.7.2 | ||
target_aws_art_al2_x64="${ECS_REPO}:${AWS_CRT_AL2_X64_SUFFIX}_${BUILDER_VERSION}" | ||
tag_and_push_img "${AWS_CRT_AL2_X64}" "${target_aws_art_al2_x64}" | ||
# Push aws-crt-ubuntu-16-x64_v0.7.2 | ||
target_aws_art_ubuntu_16_x64="${ECS_REPO}:${AWS_CRT_UBUNTU_16_X64_SUFFIX}_${BUILDER_VERSION}" | ||
tag_and_push_img "${AWS_CRT_UBUNTU_16_X64}" "${target_aws_art_ubuntu_16_x64}" | ||
} |
This file contains 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 @@ | ||
#!/bin/bash -ex | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
function validate_input() { | ||
key="${1}" | ||
value="${2}" | ||
if [[ -z "${value}" ]]; then | ||
echo "The value of ${key} is empty." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Tag images with date to help find old images, CodeBuild uses the latest tag and gets updated automatically. | ||
function tag_and_push_img() { | ||
source="${1}" | ||
validate_input 'source' "${source}" | ||
target="${2}" | ||
validate_input 'target' "${target}" | ||
img_push_date=$(date +%Y-%m-%d) | ||
docker_img_with_latest="${target}_latest" | ||
docker_img_with_date="${target}_${img_push_date}" | ||
docker tag "${source}" "${docker_img_with_latest}" | ||
docker tag "${source}" "${docker_img_with_date}" | ||
docker push "${docker_img_with_latest}" | ||
docker push "${docker_img_with_date}" | ||
} |
This file contains 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,10 @@ | ||
#!/bin/bash -ex | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Note: this file is reserved for pulling Docker images from 'docker.pkg.github.com', which needs external credential. | ||
# Pull Docker images used by https://github.com/awslabs/aws-c-cal | ||
# These Docker images are hosted in 'docker.pkg.github.com', which needs GitHub personal access token. | ||
source ./aws-crt/aws-crt-common.sh | ||
login_github_docker_pkg | ||
pull_aws_crt_docker_img |
This file contains 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
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.
From what I understand, the handling of CRT images is different from the rest of the images, correct? Can this be briefly described here? CRT is Common Runtime?
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.
This
README.md
is overview oflinux-x86
Docker images build. I added somecrt
related comments inaws-crt-common.sh
.