Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup binary build workflows/scripts #1564

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build_python_runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ 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"
steps:
- 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:
Expand All @@ -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}"
6 changes: 3 additions & 3 deletions builds/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*

Expand Down
15 changes: 7 additions & 8 deletions builds/build_python_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"