From c32d02967166621d948166e642b1b621ca0038cb Mon Sep 17 00:00:00 2001 From: Leo Herran <25494661+leoherran-aws@users.noreply.github.com> Date: Fri, 28 Jul 2023 09:07:09 -0700 Subject: [PATCH] Fix SAM CLI installation and add Docker entrypoint to corretto images (#661) --- al2/x86_64/standard/5.0/Dockerfile | 8 ++++--- al2/x86_64/standard/corretto11/Dockerfile | 6 +++-- .../standard/corretto11/dockerd-entrypoint.sh | 23 +++++++++++++++++++ al2/x86_64/standard/corretto8/Dockerfile | 6 +++-- .../standard/corretto8/dockerd-entrypoint.sh | 23 +++++++++++++++++++ ubuntu/standard/6.0/Dockerfile | 6 +++-- ubuntu/standard/7.0/Dockerfile | 8 ++++--- 7 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 al2/x86_64/standard/corretto11/dockerd-entrypoint.sh create mode 100644 al2/x86_64/standard/corretto8/dockerd-entrypoint.sh diff --git a/al2/x86_64/standard/5.0/Dockerfile b/al2/x86_64/standard/5.0/Dockerfile index a4e5ee0f..047f829d 100644 --- a/al2/x86_64/standard/5.0/Dockerfile +++ b/al2/x86_64/standard/5.0/Dockerfile @@ -277,15 +277,17 @@ RUN rbenv install $RUBY_32_VERSION && rm -rf /tmp/* && rbenv global $RUBY_32_VER #Python 3.11 ENV PYTHON_311_VERSION="3.11.4" ENV PYTHON_PIP_VERSION=23.1.2 -ENV PYYAML_VERSION=6.0 +ENV PYYAML_VERSION=5.4.1 COPY tools/runtime_configs/python/$PYTHON_311_VERSION /root/.pyenv/plugins/python-build/share/python-build/$PYTHON_311_VERSION RUN env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYTHON_311_VERSION && rm -rf /tmp/* RUN pyenv global $PYTHON_311_VERSION RUN set -ex \ && pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \ - && pip3 install --no-cache-dir --upgrade 'setuptools==67.7.2' wheel aws-sam-cli boto3 pipenv virtualenv \ - && pip3 install --no-cache-dir --upgrade "PyYAML==$PYYAML_VERSION" + && pip3 install wheel \ + && pip3 install --no-build-isolation "Cython<3" "PyYAML==$PYYAML_VERSION" \ + && pip3 install --no-cache-dir --upgrade 'setuptools==67.7.2' aws-sam-cli boto3 pipenv virtualenv \ + && pip3 uninstall cython --yes #**************** END PYTHON ***************************************************** diff --git a/al2/x86_64/standard/corretto11/Dockerfile b/al2/x86_64/standard/corretto11/Dockerfile index e61687d8..651be81b 100644 --- a/al2/x86_64/standard/corretto11/Dockerfile +++ b/al2/x86_64/standard/corretto11/Dockerfile @@ -22,7 +22,7 @@ RUN set -ex \ && ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H github.com >> ~/.ssh/known_hosts \ && ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H bitbucket.org >> ~/.ssh/known_hosts \ && chmod 600 ~/.ssh/known_hosts \ - && yum install -y -q make gettext-devel gcc openssl-devel curl-devel expat-devel + && yum install -y -q make gettext-devel gcc openssl-devel curl-devel expat-devel iptables RUN useradd codebuild-user @@ -111,6 +111,8 @@ RUN set -ex \ # Configure SSH COPY ssh_config /root/.ssh/config COPY runtimes.yml /codebuild/image/config/runtimes.yml +COPY dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh +RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh COPY legal/bill_of_material.txt /usr/share/doc/bill_of_material.txt -ENTRYPOINT ["sh","-c"] +ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"] \ No newline at end of file diff --git a/al2/x86_64/standard/corretto11/dockerd-entrypoint.sh b/al2/x86_64/standard/corretto11/dockerd-entrypoint.sh new file mode 100644 index 00000000..fa13d346 --- /dev/null +++ b/al2/x86_64/standard/corretto11/dockerd-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +/usr/local/bin/dockerd \ + --host=unix:///var/run/docker.sock \ + --host=tcp://127.0.0.1:2375 \ + --storage-driver=overlay2 &>/var/log/docker.log & + + +tries=0 +d_timeout=60 +until docker info >/dev/null 2>&1 +do + if [ "$tries" -gt "$d_timeout" ]; then + cat /var/log/docker.log + echo 'Timed out trying to connect to internal docker host.' >&2 + exit 1 + fi + tries=$(( $tries + 1 )) + sleep 1 +done + +eval "$@" diff --git a/al2/x86_64/standard/corretto8/Dockerfile b/al2/x86_64/standard/corretto8/Dockerfile index e9d4f09f..1409e94c 100644 --- a/al2/x86_64/standard/corretto8/Dockerfile +++ b/al2/x86_64/standard/corretto8/Dockerfile @@ -22,7 +22,7 @@ RUN set -ex \ && ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H github.com >> ~/.ssh/known_hosts \ && ssh-keyscan -t rsa,dsa,ed25519,ecdsa -H bitbucket.org >> ~/.ssh/known_hosts \ && chmod 600 ~/.ssh/known_hosts \ - && yum install -y -q make gettext-devel gcc openssl-devel curl-devel expat-devel + && yum install -y -q make gettext-devel gcc openssl-devel curl-devel expat-devel iptables RUN useradd codebuild-user @@ -111,6 +111,8 @@ RUN set -ex \ # Configure SSH COPY ssh_config /root/.ssh/config COPY runtimes.yml /codebuild/image/config/runtimes.yml +COPY dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh +RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh COPY legal/bill_of_material.txt /usr/share/doc/bill_of_material.txt -ENTRYPOINT ["sh","-c"] +ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"] \ No newline at end of file diff --git a/al2/x86_64/standard/corretto8/dockerd-entrypoint.sh b/al2/x86_64/standard/corretto8/dockerd-entrypoint.sh new file mode 100644 index 00000000..fa13d346 --- /dev/null +++ b/al2/x86_64/standard/corretto8/dockerd-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +/usr/local/bin/dockerd \ + --host=unix:///var/run/docker.sock \ + --host=tcp://127.0.0.1:2375 \ + --storage-driver=overlay2 &>/var/log/docker.log & + + +tries=0 +d_timeout=60 +until docker info >/dev/null 2>&1 +do + if [ "$tries" -gt "$d_timeout" ]; then + cat /var/log/docker.log + echo 'Timed out trying to connect to internal docker host.' >&2 + exit 1 + fi + tries=$(( $tries + 1 )) + sleep 1 +done + +eval "$@" diff --git a/ubuntu/standard/6.0/Dockerfile b/ubuntu/standard/6.0/Dockerfile index 5e3af38d..6e985ff2 100644 --- a/ubuntu/standard/6.0/Dockerfile +++ b/ubuntu/standard/6.0/Dockerfile @@ -210,8 +210,10 @@ RUN env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYTHON_310_VERS RUN pyenv global $PYTHON_310_VERSION RUN set -ex \ && pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \ - && pip3 install --no-cache-dir --upgrade "PyYAML==$PYYAML_VERSION" \ - && pip3 install --no-cache-dir --upgrade 'setuptools==62.6.0' wheel aws-sam-cli boto3 pipenv virtualenv + && pip3 install wheel \ + && pip3 install --no-build-isolation "Cython<3" "PyYAML==$PYYAML_VERSION" \ + && pip3 install --no-cache-dir --upgrade 'setuptools==62.6.0' aws-sam-cli boto3 pipenv virtualenv \ + && pip3 uninstall cython --yes #**************** END PYTHON ***************************************************** diff --git a/ubuntu/standard/7.0/Dockerfile b/ubuntu/standard/7.0/Dockerfile index 4685000f..368dda12 100644 --- a/ubuntu/standard/7.0/Dockerfile +++ b/ubuntu/standard/7.0/Dockerfile @@ -203,15 +203,17 @@ RUN rbenv install $RUBY_32_VERSION && rm -rf /tmp/* \ ENV PYTHON_311_VERSION="3.11.4" ARG PYTHON_PIP_VERSION=23.1.1 -ENV PYYAML_VERSION=6.0 +ENV PYYAML_VERSION=5.4.1 COPY tools/runtime_configs/python/$PYTHON_311_VERSION /root/.pyenv/plugins/python-build/share/python-build/$PYTHON_311_VERSION RUN env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYTHON_311_VERSION && rm -rf /tmp/* RUN pyenv global $PYTHON_311_VERSION RUN set -ex \ && pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \ - && pip3 install --no-cache-dir --upgrade 'setuptools==67.7.2' wheel aws-sam-cli boto3 pipenv virtualenv \ - && pip3 install --no-cache-dir --upgrade "PyYAML==$PYYAML_VERSION" + && pip3 install wheel \ + && pip3 install --no-build-isolation "Cython<3" "PyYAML==$PYYAML_VERSION" \ + && pip3 install --no-cache-dir --upgrade 'setuptools==67.7.2' aws-sam-cli boto3 pipenv virtualenv \ + && pip3 uninstall cython --yes #**************** END PYTHON *****************************************************