From f9f6892f3285e82e0dd641e37c330e8ada7d4088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 2 Aug 2023 10:02:56 +0200 Subject: [PATCH 1/2] fix: pip, black, setuptools, twine, wheel, and aws-sam-cli incorrectly installed in superchain The packages were installed in a virtual environment, which is not subsequently re-activated in the image's ENTRYPOINT. Instead, install the packages 'globally' --- superchain/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/superchain/Dockerfile b/superchain/Dockerfile index ca27a1ad41..7675644447 100644 --- a/superchain/Dockerfile +++ b/superchain/Dockerfile @@ -166,8 +166,6 @@ ENV PATH=$PATH:${CARGO_HOME}/bin # Install Python 3 RUN apt-get update \ && apt-get -y install python3 python3-dev python3-pip python3-venv \ - && python3 -m venv .venv \ - && source .venv/bin/activate \ && python3 -m pip install --no-input --upgrade pip \ && python3 -m pip install --no-input --upgrade black setuptools twine wheel aws-sam-cli \ && rm -rf $(pip cache dir) \ From eb6317cd11faf905c13f6a05af26ef16184d9a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 2 Aug 2023 11:10:54 +0200 Subject: [PATCH 2/2] install python via pyenv instead of apt --- superchain/Dockerfile | 26 +++++++++++++++++++++----- superchain/build-local.sh | 11 ++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/superchain/Dockerfile b/superchain/Dockerfile index 7675644447..e85e866e21 100644 --- a/superchain/Dockerfile +++ b/superchain/Dockerfile @@ -125,6 +125,7 @@ ENV LANG="C.UTF-8" RUN apt-get update \ && apt-get -y upgrade \ && apt-get -y install --no-install-recommends \ + acl \ apt-transport-https \ build-essential \ ca-certificates \ @@ -133,15 +134,24 @@ RUN apt-get update git \ gnupg \ gzip \ + libbz2-dev \ libffi-dev \ libicu-dev \ + liblzma-dev \ + libncursesw5-dev \ + libreadline-dev \ + libsqlite3-dev \ libssl-dev \ + libxml2-dev \ + libxmlsec1-dev \ openssl \ rsync \ sudo \ + tk-dev \ unzip \ + xz-utils \ zip \ - acl \ + zlib1g-dev \ && rm -rf /var/lib/apt/lists/* # Install mono @@ -164,8 +174,12 @@ RUN set -eo pipefail ENV PATH=$PATH:${CARGO_HOME}/bin # Install Python 3 -RUN apt-get update \ - && apt-get -y install python3 python3-dev python3-pip python3-venv \ +ENV PYENV_ROOT="/opt/pyenv" +RUN curl -fSsL "https://pyenv.run" | bash \ + && command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" \ + && eval "$(pyenv init -)" \ + && PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto' pyenv install 3.8 \ + && pyenv global 3.8 \ && python3 -m pip install --no-input --upgrade pip \ && python3 -m pip install --no-input --upgrade black setuptools twine wheel aws-sam-cli \ && rm -rf $(pip cache dir) \ @@ -395,8 +409,10 @@ ENV LANG="C.UTF-8" \ GOROOT="/opt/golang/go" \ RUSTUP_HOME="/usr/local/rustup" \ - CARGO_HOME="/usr/local/cargo" -ENV PATH="${PATH}:${CARGO_HOME}/bin:${GOROOT}/bin:${M2}" + CARGO_HOME="/usr/local/cargo" \ + \ + PYENV_ROOT="/opt/pyenv" +ENV PATH="${PYENV_ROOT}/shims:${PATH}:${CARGO_HOME}/bin:${GOROOT}/bin:${M2}:${PYENV_ROOT}/bin" COPY --from=staging / / VOLUME /var/lib/docker diff --git a/superchain/build-local.sh b/superchain/build-local.sh index ef7fceac3d..23e48143e6 100755 --- a/superchain/build-local.sh +++ b/superchain/build-local.sh @@ -24,8 +24,17 @@ if [[ "${PLATFORM}" == "x86_64" ]]; then PLATFORM="amd64" fi +if command -v docker >/dev/null; then + DOCKER=docker +elif command -v finch >/dev/null; then + DOCKER=finch +else + echo "Could not find 'docker' or 'finch' in PATH, aborting..." + exit 1 +fi + # Now on to building the image -${DOCKER:-docker} build \ +${DOCKER} build \ --target superchain \ --build-arg BUILDPLATFORM=linux/${PLATFORM} \ --build-arg TARGETPLATFORM=linux/${PLATFORM} \