Skip to content

Commit

Permalink
Builders and buildpacks for host platform arch
Browse files Browse the repository at this point in the history
When running on amd64 build builders and buildpacks for that
architecture.  Similarly, support arm64 on arm64.

Signed-off-by: Aidan Delaney <adelaney21@bloomberg.net>
  • Loading branch information
AidanDelaney committed Jan 11, 2023
1 parent 1fe27eb commit 0dec0e9
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 10 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,45 @@ jobs:
run: make deploy-linux deploy-wine
- name: Clean up
run: make clean-linux clean-wine
build-deploy-linux-arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine download URL for latest pack
id: pack-download-url
uses: actions/github-script@0.4.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
return github.repos.getLatestRelease({
owner: "buildpacks",
repo: "pack"
}).then(result => {
return result.data.assets
.filter(a => a.name.includes("-linux-arm64.tgz"))
.map(a => a.browser_download_url)[0];
})
- name: Install pack
run: |
curl -s -L -o pack.tgz ${{ steps.pack-download-url.outputs.result }}
tar -xvf pack.tgz
- name: Set config needed for image extensions
run: |
./pack config experimental true
./pack config pull-policy always
- name: Build
run: PACK_CMD=./pack make build-linux-stacks
- uses: azure/docker-login@v1
if: (github.event_name == 'repository_dispatch') || (github.event_name == 'push' && github.ref == 'refs/heads/main')
with:
username: cnbs
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Deploy
if: (github.event_name == 'repository_dispatch') || (github.event_name == 'push' && github.ref == 'refs/heads/main')
run: make deploy-linux
- name: Clean up
run: make clean-linux
build-deploy-windows:
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ build-bionic: build-stack-bionic build-builder-bionic build-buildpacks-bionic

build-stack-alpine:
@echo "> Building 'alpine' stack..."
bash stacks/build-stack.sh stacks/alpine
bash stacks/build-stack.sh -p $(shell uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) stacks/alpine

build-stack-bionic:
@echo "> Building 'bionic' stack..."
bash stacks/build-stack.sh stacks/bionic
bash stacks/build-stack.sh -p $(shell uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) stacks/bionic

build-linux-builders: build-builder-alpine build-builder-bionic

Expand Down
5 changes: 3 additions & 2 deletions buildpacks/java-maven/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ if compgen -G "${env_dir}/*" > /dev/null; then
fi

# 3. INSTALL JAVA
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_x64.tar.gz"
HOST_PLATFORM=$(uname -m | sed s/aarch64/amd64/ | sed s/x86_64/x64/)
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_${HOST_PLATFORM}.tar.gz"
jdk_version="1.8.0_222"

if [[ -r /etc/alpine-release ]]; then
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_musl_x64.tar.gz"
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_musl_${HOST_PLATFORM}.tar.gz"
jdk_version="1.8.0_222"
fi

Expand Down
5 changes: 3 additions & 2 deletions buildpacks/kotlin-gradle/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ if compgen -G "${env_dir}/*" > /dev/null; then
fi

# 3. INSTALL JAVA
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_x64.tar.gz"
HOST_PLATFORM=$(uname -m | sed s/aarch64/amd64/ | sed s/x86_64/x64/)
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_${HOST_PLATFORM}.tar.gz"
jdk_version="1.8.0_222"

if [[ -r /etc/alpine-release ]]; then
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_musl_x64.tar.gz"
jdk_url="https://cdn.azul.com/zulu/bin/zulu8.40.0.25-ca-jdk8.0.222-linux_musl_${HOST_PLATFORM}.tar.gz"
jdk_version="1.8.0_222"
fi

Expand Down
3 changes: 2 additions & 1 deletion buildpacks/ruby-bundler/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ mkdir -p "${ruby_layer_dir}"
ruby_version=$(cat "${plan_path}" | yj -t | jq -r '.entries[] | select(.name == "ruby") | .version')

echo "---> Downloading and extracting Ruby ${ruby_version}"
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-${ruby_version}.tgz
HOST_PLATFORM=$(uname -m | sed s/aarch64/amd64/ | sed s/x86_64/x64/)
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-${ruby_version}-${HOST_PLATFORM}.tgz
wget -q -O - "${ruby_url}" | tar -xzf - -C "${ruby_layer_dir}"

# 3. MAKE RUBY AVAILABLE DURING LAUNCH
Expand Down
6 changes: 3 additions & 3 deletions stacks/build-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ RUN_IMAGE=${REPO_PREFIX}-run:${TAG}
BUILD_IMAGE=${REPO_PREFIX}-build:${TAG}

if [[ -d "${IMAGE_DIR}/base" ]]; then
docker build --platform=${PLATFORM} -t "${BASE_IMAGE}" "${IMAGE_DIR}/base"
docker buildx build --platform=linux/${PLATFORM} -t "${BASE_IMAGE}" "${IMAGE_DIR}/base"
fi

echo "BUILDING ${BUILD_IMAGE}..."
docker build --platform=${PLATFORM} --build-arg "base_image=${BASE_IMAGE}" --build-arg "stack_id=${STACK_ID}" -t "${BUILD_IMAGE}" "${IMAGE_DIR}/build"
docker buildx build --platform=linux/${PLATFORM} --build-arg "base_image=${BASE_IMAGE}" --build-arg "stack_id=${STACK_ID}" -t "${BUILD_IMAGE}" "${IMAGE_DIR}/build"

echo "BUILDING ${RUN_IMAGE}..."
docker build --platform=${PLATFORM} --build-arg "base_image=${BASE_IMAGE}" --build-arg "stack_id=${STACK_ID}" -t "${RUN_IMAGE}" "${IMAGE_DIR}/run"
docker buildx build --platform=linux/${PLATFORM} --build-arg "base_image=${BASE_IMAGE}" --build-arg "stack_id=${STACK_ID}" -t "${RUN_IMAGE}" "${IMAGE_DIR}/run"

echo
echo "STACK BUILT!"
Expand Down

0 comments on commit 0dec0e9

Please sign in to comment.