Skip to content

Commit

Permalink
Update build script for multiarch heroku-24
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Jan 18, 2024
1 parent a2ecf31 commit 6c17f4f
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,44 @@ write_package_list() {
docker run --rm "$image_tag" dpkg-query --show --showformat='${Package}\n' >> "$output_file"
}

RUN_IMAGE_TAG="heroku/heroku:${STACK_VERSION}"
RUN_DOCKERFILE_DIR="heroku-${STACK_VERSION}"

BUILD_IMAGE_TAG="heroku/heroku:${STACK_VERSION}-build"
BUILD_DOCKERFILE_DIR="${RUN_DOCKERFILE_DIR}-build"

if [ $STACK_VERSION -ge 24 ]; then
# heroku/heroku:24 images and beyond are multiarch images. Additionally,
# the CNB specific modifications are included, and separate *cnb* variants
# do not exist.
# the CNB specific modifications are included (separate *cnb* variants
# do not exist).

# NOTE: To build multiarch images with buildx, setup a builder that uses
# the `docker-container` driver, and/or turn on the `containerd`
# snapshotter storage. https://docs.docker.com/build/building/multi-platform/

RUN_IMAGE_TAG="heroku/heroku:${STACK_VERSION}"
RUN_DOCKERFILE_DIR="heroku-${STACK_VERSION}"
[[ -d "${RUN_DOCKERFILE_DIR}" ]] || abort "fatal: directory ${RUN_DOCKERFILE_DIR} not found"
display "Building ${RUN_DOCKERFILE_DIR} / ${RUN_IMAGE_TAG} Heroku runtime image"
display "Building ${RUN_DOCKERFILE_DIR} / ${RUN_IMAGE_TAG} Heroku runtime multiarch image"
docker buildx build --platform "linux/amd64,linux/arm64" --pull --tag "${RUN_IMAGE_TAG}" "${RUN_DOCKERFILE_DIR}" | indent
write_package_list "${RUN_IMAGE_TAG}" "${RUN_DOCKERFILE_DIR}"


BUILD_IMAGE_TAG="heroku/heroku:${STACK_VERSION}"
BUILD_DOCKERFILE_DIR="heroku-${STACK_VERSION}"
# The --pull option is not used for variants to ensure they are based on the
# runtime stack image built above, rather than the one last published to DockerHub.
[[ -d "${BUILD_DOCKERFILE_DIR}" ]] || abort "fatal: directory ${BUILD_DOCKERFILE_DIR} not found"
display "Building ${BUILD_DOCKERFILE_DIR} / ${BUILD_IMAGE_TAG} Heroku build-time image"
docker buildx build --platform "linux/amd64" --tag "${BUILD_IMAGE_TAG}" "${BUILD_DOCKERFILE_DIR}" | indent
write_package_list "${AMD_BUILD_IMAGE_TAG}" "${BUILD_DOCKERFILE_DIR}"

display "Building ${BUILD_DOCKERFILE_DIR} / ${BUILD_IMAGE_TAG} Heroku build-time multiarch image"
docker buildx build --platform "linux/amd64,linux/arm64" --tag "${BUILD_IMAGE_TAG}" "${BUILD_DOCKERFILE_DIR}" | indent
write_package_list "${BUILD_IMAGE_TAG}" "${BUILD_DOCKERFILE_DIR}"
else
# heroku/heroku:22 and prior does not support multiple chip architectures
# or multiarch images. Additionally, they include *cnb* variants that
# are separate from variants targeted at heroku classic.
# or multiarch images. Additionally, separate *cnb* variants are created
# which add compatibility for Cloud Native Buildpacks.

RUN_IMAGE_TAG="heroku/heroku:${STACK_VERSION}"
RUN_DOCKERFILE_DIR="heroku-${STACK_VERSION}"
[[ -d "${RUN_DOCKERFILE_DIR}" ]] || abort "fatal: directory ${RUN_DOCKERFILE_DIR} not found"
display "Building ${RUN_DOCKERFILE_DIR} / ${RUN_IMAGE_TAG} Heroku runtime image"
docker build --pull --tag "${RUN_IMAGE_TAG}" "${RUN_DOCKERFILE_DIR}" | indent
write_package_list "${RUN_IMAGE_TAG}" "${RUN_DOCKERFILE_DIR}"

# The --pull option is not used for variants to ensure they are based on the
# runtime stack image built above, rather than the one last published to DockerHub.

BUILD_IMAGE_TAG="${RUN_IMAGE_TAG}-build"
BUILD_DOCKERFILE_DIR="${RUN_DOCKERFILE_DIR}-build"
display "Building ${BUILD_DOCKERFILE_DIR} / ${BUILD_IMAGE_TAG} Heroku build-time image"
docker build --tag "$BUILD_IMAGE_TAG" "$BUILD_DOCKERFILE_DIR" | indent
write_package_list "$BUILD_IMAGE_TAG" "$BUILD_DOCKERFILE_DIR"
Expand Down

0 comments on commit 6c17f4f

Please sign in to comment.