diff --git a/.github/workflows/build_python_runtime.yml b/.github/workflows/build_python_runtime.yml index d47fefcaa..8b29a41e8 100644 --- a/.github/workflows/build_python_runtime.yml +++ b/.github/workflows/build_python_runtime.yml @@ -26,7 +26,7 @@ env: # Unfortunately these jobs cannot be easily written as a matrix since `matrix.exclude` does not # support expression syntax, and the `inputs` context is not available inside the job `if` key. jobs: - build-and-upload-heroku-20: + heroku-20: runs-on: pub-hk-ubuntu-22.04-xlarge env: STACK_VERSION: "20" @@ -34,15 +34,15 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Build Docker image - run: docker build --pull --tag buildenv --build-arg=STACK_VERSION builds/ + run: docker build --platform="linux/amd64" --pull --tag buildenv --build-arg=STACK_VERSION builds/ - name: Build and package Python runtime - run: docker run --rm --platform="linux/amd64" --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}" + run: docker run --rm --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}" - name: Upload Python runtime archive to S3 if: (!inputs.dry_run) run: aws s3 sync ./upload "s3://${S3_BUCKET}" - build-and-upload-heroku-22: - # We only support Python 3.9+ on Heroku-22. + heroku-22: + # On Heroku-22 we only support Python 3.9+. if: (!startsWith(inputs.python_version,'3.8.')) runs-on: pub-hk-ubuntu-22.04-xlarge env: @@ -51,9 +51,9 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Build Docker image - run: docker build --pull --tag buildenv --build-arg=STACK_VERSION builds/ + run: docker build --platform="linux/amd64" --pull --tag buildenv --build-arg=STACK_VERSION builds/ - name: Build and package Python runtime - run: docker run --rm --platform="linux/amd64" --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}" + run: docker run --rm --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}" - name: Upload Python runtime archive to S3 if: (!inputs.dry_run) run: aws s3 sync ./upload "s3://${S3_BUCKET}" diff --git a/builds/Dockerfile b/builds/Dockerfile index 37e25c26f..84672acb0 100644 --- a/builds/Dockerfile +++ b/builds/Dockerfile @@ -1,11 +1,11 @@ ARG STACK_VERSION="22" -FROM --platform=linux/amd64 heroku/heroku:${STACK_VERSION}-build +FROM heroku/heroku:${STACK_VERSION}-build ARG STACK_VERSION ENV STACK="heroku-${STACK_VERSION}" -RUN apt-get update \ - && apt-get install --no-install-recommends -y \ +RUN apt-get update --error-on=any \ + && apt-get install -y --no-install-recommends \ libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* diff --git a/builds/build_python_runtime.sh b/builds/build_python_runtime.sh index 379505e63..4735039f0 100755 --- a/builds/build_python_runtime.sh +++ b/builds/build_python_runtime.sh @@ -7,7 +7,7 @@ PYTHON_MAJOR_VERSION="${PYTHON_VERSION%.*}" INSTALL_DIR="/app/.heroku/python" SRC_DIR="/tmp/src" -ARCHIVES_DIR="/tmp/upload/${STACK}/runtimes" +UPLOAD_DIR="/tmp/upload/${STACK}/runtimes" function error() { echo "Error: ${1}" >&2 @@ -67,7 +67,7 @@ SIGNATURE_URL="${SOURCE_URL}.asc" set -o xtrace -mkdir -p "${SRC_DIR}" "${INSTALL_DIR}" "${ARCHIVES_DIR}" +mkdir -p "${SRC_DIR}" "${INSTALL_DIR}" "${UPLOAD_DIR}" curl --fail --retry 3 --retry-connrefused --connect-timeout 10 --max-time 60 -o python.tgz "${SOURCE_URL}" curl --fail --retry 3 --retry-connrefused --connect-timeout 10 --max-time 60 -o python.tgz.asc "${SIGNATURE_URL}" @@ -191,13 +191,12 @@ LD_LIBRARY_PATH="${SRC_DIR}" "${SRC_DIR}/python" -m compileall -f --invalidation # This symlink must be relative, to ensure that the Python install remains relocatable. ln -srvT "${INSTALL_DIR}/bin/python3" "${INSTALL_DIR}/bin/python" -cd "${ARCHIVES_DIR}" - # The tar file is gzipped separately, so we can set a higher gzip compression level than # the default. In the future we'll also want to create a second archive that used zstd. -TAR_FILENAME="python-${PYTHON_VERSION}.tar" -tar --create --format=pax --sort=name --verbose --file "${TAR_FILENAME}" --directory="${INSTALL_DIR}" . -gzip --best "${TAR_FILENAME}" +# Results in a compressed archive filename of form: 'python-X.Y.Z.tar.gz' +TAR_FILEPATH="${UPLOAD_DIR}/python-${PYTHON_VERSION}.tar" +tar --create --format=pax --sort=name --file "${TAR_FILEPATH}" --directory="${INSTALL_DIR}" . +gzip --best "${TAR_FILEPATH}" du --max-depth 1 --human-readable "${INSTALL_DIR}" -du --all --human-readable "${ARCHIVES_DIR}" +du --all --human-readable "${UPLOAD_DIR}"