From ed40c1912eef8abcb5e90743151f255ebb998f49 Mon Sep 17 00:00:00 2001 From: DmitriyMusatkin Date: Tue, 3 Dec 2024 13:39:29 -0800 Subject: [PATCH] ensure that al2 image is actually al2 --- .github/docker-images/al2-2023/Dockerfile | 47 +++++++++++++++++++++++ .github/docker-images/al2-x64/Dockerfile | 2 +- builder/core/host.py | 6 ++- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .github/docker-images/al2-2023/Dockerfile diff --git a/.github/docker-images/al2-2023/Dockerfile b/.github/docker-images/al2-2023/Dockerfile new file mode 100644 index 000000000..b704db46f --- /dev/null +++ b/.github/docker-images/al2-2023/Dockerfile @@ -0,0 +1,47 @@ +FROM amazonlinux:2 + + +############################################################################### +# Install prereqs +############################################################################### +RUN yum -y update \ + && yum -y install \ + tar \ + git \ + sudo \ + # Python + python3 \ + python3-devel \ + python3-pip \ + make \ + cmake3 \ + gcc \ + gcc-c++ \ + which \ + && yum clean all \ + && rm -rf /var/cache/yum \ + && cmake --version \ + && ctest --version + +############################################################################### +# Python/AWS CLI +############################################################################### +RUN python3 -m pip install setuptools virtualenv \ + && python3 -m pip install --upgrade awscli \ + && aws --version + +############################################################################### +# Install pre-built CMake +############################################################################### +WORKDIR /tmp +RUN curl -sSL https://d19elf31gohf1l.cloudfront.net/_binaries/cmake/cmake-3.13-manylinux1-x64.tar.gz -o cmake.tar.gz \ + && tar xvzf cmake.tar.gz -C /usr/local \ + && cmake --version \ + && rm -f /tmp/cmake.tar.gz + +############################################################################### +# Install entrypoint +############################################################################### +ADD entrypoint.sh /usr/local/bin/builder +RUN chmod a+x /usr/local/bin/builder +ENTRYPOINT ["/usr/local/bin/builder"] diff --git a/.github/docker-images/al2-x64/Dockerfile b/.github/docker-images/al2-x64/Dockerfile index b8228f253..eb2e7cbfb 100644 --- a/.github/docker-images/al2-x64/Dockerfile +++ b/.github/docker-images/al2-x64/Dockerfile @@ -1,4 +1,4 @@ -FROM amazonlinux:latest +FROM amazonlinux:2023 ############################################################################### diff --git a/builder/core/host.py b/builder/core/host.py index 41d3a9aca..e2e67d08e 100644 --- a/builder/core/host.py +++ b/builder/core/host.py @@ -70,7 +70,11 @@ def current_host(): def _discover_host(): platform = current_os() if platform == 'linux': - if _file_contains('/etc/system-release', 'Amazon Linux release 2'): + # Note: that AL2 and AL2023 have the same substring. Check for AL2023 explicitly. + # And also check that AL2 has "2 (", which is common to all base distributions of AL2 + if _file_contains('/etc/system-release', 'Amazon Linux release 2023'): + return 'al2023' + if _file_contains('/etc/system-release', 'Amazon Linux release 2 ('): return 'al2' if _file_contains('/etc/system-release', 'Bare Metal') or _file_contains('/etc/system-release', 'Amazon Linux AMI'): return 'al2012'