From 76aceb3ca39bef8c57d732d3f64f58d6fa084816 Mon Sep 17 00:00:00 2001 From: Lucas <12496191+lucashuy@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:46:00 -0700 Subject: [PATCH 1/4] chore: Update Python version for images that install SAM CLI from source (#106) * Install SAM CLI with the native installer and install Lambda builders for py3.7 * Update all images that build SAM CLI from source to use py38 * Fix package names * Revert test URL * Remove old Python version before trying to install newer --- build-image-src/Dockerfile-dotnet6 | 15 ++++++++++++--- build-image-src/Dockerfile-dotnet7 | 19 +++++++++++++++---- build-image-src/Dockerfile-java11 | 15 ++++++++++++--- build-image-src/Dockerfile-java17 | 15 ++++++++++++--- build-image-src/Dockerfile-java8_al2 | 17 +++++++++++++---- build-image-src/Dockerfile-nodejs12x | 15 ++++++++++++--- build-image-src/Dockerfile-nodejs14x | 15 ++++++++++++--- build-image-src/Dockerfile-nodejs16x | 15 ++++++++++++--- build-image-src/Dockerfile-nodejs18x | 16 ++++++++++++---- build-image-src/Dockerfile-provided_al2 | 15 ++++++++++++--- build-image-src/Dockerfile-python37 | 22 ++++++++++++++-------- build-image-src/Dockerfile-ruby27 | 15 ++++++++++++--- build-image-src/Dockerfile-ruby32 | 15 ++++++++++++--- 13 files changed, 162 insertions(+), 47 deletions(-) diff --git a/build-image-src/Dockerfile-dotnet6 b/build-image-src/Dockerfile-dotnet6 index f4e23b5..f266365 100644 --- a/build-image-src/Dockerfile-dotnet6 +++ b/build-image-src/Dockerfile-dotnet6 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -19,8 +18,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-dotnet7 b/build-image-src/Dockerfile-dotnet7 index e9031e9..780bc90 100644 --- a/build-image-src/Dockerfile-dotnet7 +++ b/build-image-src/Dockerfile-dotnet7 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -19,12 +18,24 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ + amazon-linux-extras \ clang krb5-devel \ openssl-devel \ llvm \ - libicu \ - && yum clean all + libicu + +RUN yum remove -y python3 python3-devel + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-java11 b/build-image-src/Dockerfile-java11 index e5b325e..4f53d1b 100644 --- a/build-image-src/Dockerfile-java11 +++ b/build-image-src/Dockerfile-java11 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -19,8 +18,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-java17 b/build-image-src/Dockerfile-java17 index b83a0c7..8620823 100644 --- a/build-image-src/Dockerfile-java17 +++ b/build-image-src/Dockerfile-java17 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -19,8 +18,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-java8_al2 b/build-image-src/Dockerfile-java8_al2 index f0b68f2..c19d485 100644 --- a/build-image-src/Dockerfile-java8_al2 +++ b/build-image-src/Dockerfile-java8_al2 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -21,9 +20,19 @@ RUN yum groupinstall -y development && \ liblzma-dev \ libxslt-devel \ libmpc-devel \ - python3-devel \ - java-1.8.0-openjdk-devel \ - && yum clean all + amazon-linux-extras \ + java-1.8.0-openjdk-devel + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-nodejs12x b/build-image-src/Dockerfile-nodejs12x index 25c961d..845fe53 100644 --- a/build-image-src/Dockerfile-nodejs12x +++ b/build-image-src/Dockerfile-nodejs12x @@ -12,7 +12,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -24,8 +23,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-nodejs14x b/build-image-src/Dockerfile-nodejs14x index 049ff54..a833082 100644 --- a/build-image-src/Dockerfile-nodejs14x +++ b/build-image-src/Dockerfile-nodejs14x @@ -12,7 +12,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -24,8 +23,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-nodejs16x b/build-image-src/Dockerfile-nodejs16x index 3baf902..262f62a 100644 --- a/build-image-src/Dockerfile-nodejs16x +++ b/build-image-src/Dockerfile-nodejs16x @@ -12,7 +12,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -24,8 +23,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-nodejs18x b/build-image-src/Dockerfile-nodejs18x index 3c2564d..df6b603 100644 --- a/build-image-src/Dockerfile-nodejs18x +++ b/build-image-src/Dockerfile-nodejs18x @@ -6,14 +6,12 @@ ENV PATH=/var/lang/bin:$PATH \ AWS_EXECUTION_ENV=AWS_Lambda_nodejs18.x \ NODE_PATH=/opt/nodejs/node18/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules -# Installing by yum at copied location RUN yum groupinstall -y development && \ yum install -d1 -y \ yum \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -25,8 +23,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-provided_al2 b/build-image-src/Dockerfile-provided_al2 index 9cf490c..4973ae6 100644 --- a/build-image-src/Dockerfile-provided_al2 +++ b/build-image-src/Dockerfile-provided_al2 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -21,8 +20,18 @@ RUN yum groupinstall -y development && \ liblzma-dev \ libxslt-devel \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version # Install AWS CLI ARG AWS_CLI_ARCH diff --git a/build-image-src/Dockerfile-python37 b/build-image-src/Dockerfile-python37 index 10006b0..8fdbcb8 100644 --- a/build-image-src/Dockerfile-python37 +++ b/build-image-src/Dockerfile-python37 @@ -27,18 +27,24 @@ RUN yum groupinstall -y development && \ # Install AWS CLI RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install && rm awscliv2.zip && rm -rf ./aws -# Install SAM CLI in a dedicated Python virtualenv +# Install SAM CLI via native linux installer ARG SAM_CLI_VERSION -RUN curl -L "https://github.com/awslabs/aws-sam-cli/archive/v$SAM_CLI_VERSION.zip" -o "samcli.zip" && \ - unzip samcli.zip && python3 -m venv /usr/local/opt/sam-cli && \ - /usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install -r ./aws-sam-cli-$SAM_CLI_VERSION/requirements/base.txt && \ - /usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install ./aws-sam-cli-$SAM_CLI_VERSION && \ - rm samcli.zip && rm -rf aws-sam-cli-$SAM_CLI_VERSION - -ENV PATH=$PATH:/usr/local/opt/sam-cli/bin +RUN curl -L "https://github.com/aws/aws-sam-cli/releases/download/v$SAM_CLI_VERSION/aws-sam-cli-linux-x86_64.zip" -o "samcli.zip" && \ + unzip samcli.zip -d sam-installation && ./sam-installation/install && \ + rm samcli.zip && rm -rf sam-installation && sam --version ENV LANG=en_US.UTF-8 +# Prepare virtualenv for lambda builders +RUN python3 -m venv --without-pip /usr/local/opt/lambda-builders +RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +RUN /usr/local/opt/lambda-builders/bin/python3 get-pip.py +# Install lambda builders in a dedicated Python virtualenv +RUN AWS_LB_VERSION=$(curl -sSL https://raw.githubusercontent.com/aws/aws-sam-cli/v$SAM_CLI_VERSION/requirements/base.txt | grep aws_lambda_builders | cut -d= -f3) && \ + /usr/local/opt/lambda-builders/bin/pip3 --no-cache-dir install "aws-lambda-builders==$AWS_LB_VERSION" + +ENV PATH=$PATH:/usr/local/opt/lambda-builders/bin + # Wheel is required by SAM CLI to build libraries like cryptography. It needs to be installed in the system # Python for it to be picked up during `sam build` RUN pip3 install wheel diff --git a/build-image-src/Dockerfile-ruby27 b/build-image-src/Dockerfile-ruby27 index b48eaaa..6b8497e 100644 --- a/build-image-src/Dockerfile-ruby27 +++ b/build-image-src/Dockerfile-ruby27 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -19,8 +18,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version RUN gem update --system --no-document diff --git a/build-image-src/Dockerfile-ruby32 b/build-image-src/Dockerfile-ruby32 index b2b752c..bcebe8e 100644 --- a/build-image-src/Dockerfile-ruby32 +++ b/build-image-src/Dockerfile-ruby32 @@ -7,7 +7,6 @@ RUN yum groupinstall -y development && \ tar \ gzip \ unzip \ - python3 \ jq \ grep \ curl \ @@ -19,8 +18,18 @@ RUN yum groupinstall -y development && \ libgmp3-dev \ zlib1g-dev \ libmpc-devel \ - python3-devel \ - && yum clean all + amazon-linux-extras + +# Install extras so that Python 3.8 is installable +# https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras +RUN amazon-linux-extras enable python3.8 && \ + yum clean metadata && \ + yum install -y python38 python38-devel && \ + yum clean all && \ + ln -s /usr/bin/python3.8 /usr/bin/python3 && \ + ln -s /usr/bin/pip3.8 /usr/bin/pip3 && \ + python3 --version && \ + pip3 --version RUN gem update --system --no-document From dd95726c73bb882bb1eb6cdc23db373295c70422 Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Tue, 7 Nov 2023 15:57:29 -0800 Subject: [PATCH 2/4] fix: update root GHA definition (#107) --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e9223f..efdf0e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,9 @@ on: jobs: run-workflow: name: Parent PR Status Check - if: always() + # If any dependent jobs fails, this WF skips which won't block merging PRs + # calling always() is required for this WF to run all the time + if: github.repository_owner == 'aws' && always() runs-on: ubuntu-latest needs: - build-single-arch From 8bde5be5043a8341b7c1f77db3338b063f20cf1b Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:08:44 -0800 Subject: [PATCH 3/4] Provided.al2023 implementation (#20) (#103) * Provided.al2023 implementation (#20) * Provided.al2023 implementation * Fixed decorator for TestBIProvidedAL2023ForArm test * update BuildImageBase to allow checking for different package manager * specify qemu tag to build for arch64 * specify qemu tag to build for arch64 * Revert "specify qemu tag to build for arch64" This reverts commit 55cd71fdcecb28176d89fab4ce92f30ef44aeecb. * Revert "specify qemu tag to build for arch64" This reverts commit 71a2723451def3430e0974a2a6bc99b355ce4aa6. --------- Co-authored-by: Anton Stepanov <110172761+anton-stepanof@users.noreply.github.com> --- .github/workflows/build.yml | 1 + Makefile | 1 + build-image-src/Dockerfile-provided_al2023 | 45 ++++++++++++++++++++++ build-image-src/build_all_images.sh | 2 + pytest.ini | 1 + tests/build_image_base_test.py | 6 ++- tests/test_build_images.py | 32 +++++++++++++++ 7 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 build-image-src/Dockerfile-provided_al2023 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efdf0e2..491a536 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,7 @@ jobs: - "nodejs16x" - "nodejs18x" - "provided_al2" + - "provided_al2023" - "python38" - "python39" - "python310" diff --git a/Makefile b/Makefile index dea9150..5afeba7 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ IS_nodejs14x := nodejs14.x IS_nodejs16x := nodejs16.x IS_nodejs18x := nodejs18.x IS_provided_al2 := provided.al2 +IS_provided_al2023 := provided.al2023 IS_python38 := python3.8 IS_python39 := python3.9 IS_python310 := python3.10 diff --git a/build-image-src/Dockerfile-provided_al2023 b/build-image-src/Dockerfile-provided_al2023 new file mode 100644 index 0000000..cf2c376 --- /dev/null +++ b/build-image-src/Dockerfile-provided_al2023 @@ -0,0 +1,45 @@ +ARG IMAGE_ARCH +FROM public.ecr.aws/lambda/provided:al2023-$IMAGE_ARCH + +RUN dnf install -y tar\ + gzip \ + unzip \ + python3 \ + jq \ + grep \ + make \ + rsync \ + binutils \ + gcc-c++ \ + procps \ + libxslt-devel \ + libmpc-devel \ + python3-devel \ + && dnf clean all + +# Install AWS CLI +ARG AWS_CLI_ARCH +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-$AWS_CLI_ARCH.zip" -o "awscliv2.zip" +RUN unzip awscliv2.zip && ./aws/install && rm awscliv2.zip && rm -rf ./aws + +# Install SAM CLI in a dedicated Python virtualenv +ARG SAM_CLI_VERSION +RUN curl -L "https://github.com/awslabs/aws-sam-cli/archive/v$SAM_CLI_VERSION.zip" -o "samcli.zip" && \ + unzip samcli.zip && python3 -m venv /usr/local/opt/sam-cli && \ + /usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install -r ./aws-sam-cli-$SAM_CLI_VERSION/requirements/base.txt && \ + /usr/local/opt/sam-cli/bin/pip3 --no-cache-dir install ./aws-sam-cli-$SAM_CLI_VERSION && \ + rm samcli.zip && rm -rf aws-sam-cli-$SAM_CLI_VERSION + +ENV PATH=$PATH:/usr/local/opt/sam-cli/bin + +ENV LANG=en_US.UTF-8 + +# Wheel is required by SAM CLI to build libraries like cryptography. It needs to be installed in the system +# Python for it to be picked up during `sam build` +RUN pip3 install wheel + +COPY ATTRIBUTION.txt / + +# Compatible with initial base image +ENTRYPOINT [] +CMD ["/bin/bash"] diff --git a/build-image-src/build_all_images.sh b/build-image-src/build_all_images.sh index f054b95..bb25550 100755 --- a/build-image-src/build_all_images.sh +++ b/build-image-src/build_all_images.sh @@ -34,6 +34,7 @@ docker build -f Dockerfile-nodejs14x -t amazon/aws-sam-cli-build-image-nodejs14. docker build -f Dockerfile-nodejs16x -t amazon/aws-sam-cli-build-image-nodejs16.x:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & docker build -f Dockerfile-nodejs18x -t amazon/aws-sam-cli-build-image-nodejs18.x:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & docker build -f Dockerfile-provided_al2 -t amazon/aws-sam-cli-build-image-provided.al2:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & +docker build -f Dockerfile-provided_al2023 -t amazon/aws-sam-cli-build-image-provided.al2023:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & docker build -f Dockerfile-python38 -t amazon/aws-sam-cli-build-image-python3.8:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & docker build -f Dockerfile-python39 -t amazon/aws-sam-cli-build-image-python3.9:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & docker build -f Dockerfile-python310 -t amazon/aws-sam-cli-build-image-python3.10:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . & @@ -54,6 +55,7 @@ docker build -f Dockerfile-nodejs14x -t amazon/aws-sam-cli-build-image-nodejs14. docker build -f Dockerfile-nodejs16x -t amazon/aws-sam-cli-build-image-nodejs16.x:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-nodejs18x -t amazon/aws-sam-cli-build-image-nodejs18.x:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-provided_al2 -t amazon/aws-sam-cli-build-image-provided.al2:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & +docker build -f Dockerfile-provided_al2023 -t amazon/aws-sam-cli-build-image-provided.al2023:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-python38 -t amazon/aws-sam-cli-build-image-python3.8:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-python39 -t amazon/aws-sam-cli-build-image-python3.9:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-python310 -t amazon/aws-sam-cli-build-image-python3.10:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & diff --git a/pytest.ini b/pytest.ini index 61e6500..130da55 100644 --- a/pytest.ini +++ b/pytest.ini @@ -14,6 +14,7 @@ markers = nodejs16x nodejs18x provided_al2 + provided_al2023 python38 python39 python310 diff --git a/tests/build_image_base_test.py b/tests/build_image_base_test.py index 9292b2e..743793f 100644 --- a/tests/build_image_base_test.py +++ b/tests/build_image_base_test.py @@ -8,6 +8,7 @@ class BuildImageBase(TestCase): __test__ = False + package_managers = ["yum"] @classmethod def setUpClass(cls, runtime, dockerfile, dep_manager=None, tag="x86_64"): @@ -70,13 +71,14 @@ def test_common_packages(self): ) self.assertTrue(self.is_package_present("aws")) self.assertTrue(self.is_package_present("jq")) - self.assertTrue(self.is_package_present("yum")) + for pm in self.package_managers: + self.assertTrue(self.is_package_present(pm)) def test_sam_init(self): """ Test sam init hello world application for the given runtime and dependency manager """ - if self.runtime in ["provided", "provided.al2", "dotnet7"]: + if self.runtime in ["provided", "provided.al2", "provided.al2023", "dotnet7"]: pytest.skip("Skipping sam init test for self-provided images") sam_init = f"sam init \ diff --git a/tests/test_build_images.py b/tests/test_build_images.py index 8dcb11d..0f68170 100644 --- a/tests/test_build_images.py +++ b/tests/test_build_images.py @@ -658,3 +658,35 @@ def test_architecture(self): Test architecture of this build image """ self.assertTrue(self.is_architecture("aarch64")) + + +@pytest.mark.provided_al2023 +class TestBIProvidedAL2023(BuildImageBase): + __test__ = True + package_managers = ["dnf"] + + @classmethod + def setUpClass(cls): + super().setUpClass("provided.al2023", "Dockerfile-provided-al2023", tag="x86_64") + + def test_architecture(self): + """ + Test architecture of this build image + """ + self.assertTrue(self.is_architecture("x86_64")) + + +@pytest.mark.provided_al2023 +class TestBIProvidedAL2023ForArm(BuildImageBase): + __test__ = True + package_managers = ["dnf"] + + @classmethod + def setUpClass(cls): + super().setUpClass("provided.al2023", "Dockerfile-provided-al2023", tag="arm64") + + def test_architecture(self): + """ + Test architecture of this build image + """ + self.assertTrue(self.is_architecture("aarch64")) From 1cc3ea56f693ec8d68674af4d638fc9194c7773a Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:33:12 -0800 Subject: [PATCH 4/4] switch to use another cross-platform emulator (#108) * switch to use another cross-platform emulator * Empty-Commit * update build_all_images.sh --- Makefile | 2 +- build-image-src/build_all_images.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5afeba7..234ff02 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ build-single-arch: pre-build build-multi-arch: pre-build docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 ./build-image-src - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker run --privileged --rm tonistiigi/binfmt --install arm64 docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 ./build-image-src test: pre-build diff --git a/build-image-src/build_all_images.sh b/build-image-src/build_all_images.sh index bb25550..94a453e 100755 --- a/build-image-src/build_all_images.sh +++ b/build-image-src/build_all_images.sh @@ -44,7 +44,7 @@ docker build -f Dockerfile-ruby32 -t amazon/aws-sam-cli-build-image-ruby3.2:x86_ wait # Build arm64 images -docker run --rm --privileged multiarch/qemu-user-static --reset -p yes +docker run --privileged --rm tonistiigi/binfmt --install arm64 docker build -f Dockerfile-dotnet6 -t amazon/aws-sam-cli-build-image-dotnet6:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-dotnet7 -t amazon/aws-sam-cli-build-image-dotnet7:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . & docker build -f Dockerfile-java8_al2 -t amazon/aws-sam-cli-build-image-java8.al2:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &