Skip to content

Commit 0dec0e9

Browse files
committed
Builders and buildpacks for host platform arch
When running on amd64 build builders and buildpacks for that architecture. Similarly, support arm64 on arm64. Signed-off-by: Aidan Delaney <adelaney21@bloomberg.net>
1 parent 1fe27eb commit 0dec0e9

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,45 @@ jobs:
5151
run: make deploy-linux deploy-wine
5252
- name: Clean up
5353
run: make clean-linux clean-wine
54+
build-deploy-linux-arm64:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Determine download URL for latest pack
59+
id: pack-download-url
60+
uses: actions/github-script@0.4.0
61+
with:
62+
github-token: ${{secrets.GITHUB_TOKEN}}
63+
result-encoding: string
64+
script: |
65+
return github.repos.getLatestRelease({
66+
owner: "buildpacks",
67+
repo: "pack"
68+
}).then(result => {
69+
return result.data.assets
70+
.filter(a => a.name.includes("-linux-arm64.tgz"))
71+
.map(a => a.browser_download_url)[0];
72+
})
73+
- name: Install pack
74+
run: |
75+
curl -s -L -o pack.tgz ${{ steps.pack-download-url.outputs.result }}
76+
tar -xvf pack.tgz
77+
- name: Set config needed for image extensions
78+
run: |
79+
./pack config experimental true
80+
./pack config pull-policy always
81+
- name: Build
82+
run: PACK_CMD=./pack make build-linux-stacks
83+
- uses: azure/docker-login@v1
84+
if: (github.event_name == 'repository_dispatch') || (github.event_name == 'push' && github.ref == 'refs/heads/main')
85+
with:
86+
username: cnbs
87+
password: ${{ secrets.REGISTRY_PASSWORD }}
88+
- name: Deploy
89+
if: (github.event_name == 'repository_dispatch') || (github.event_name == 'push' && github.ref == 'refs/heads/main')
90+
run: make deploy-linux
91+
- name: Clean up
92+
run: make clean-linux
5493
build-deploy-windows:
5594
strategy:
5695
matrix:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ build-bionic: build-stack-bionic build-builder-bionic build-buildpacks-bionic
1818

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

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

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

buildpacks/java-maven/bin/build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ if compgen -G "${env_dir}/*" > /dev/null; then
1616
fi
1717

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

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

buildpacks/kotlin-gradle/bin/build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ if compgen -G "${env_dir}/*" > /dev/null; then
1616
fi
1717

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

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

buildpacks/ruby-bundler/bin/build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ mkdir -p "${ruby_layer_dir}"
1515
ruby_version=$(cat "${plan_path}" | yj -t | jq -r '.entries[] | select(.name == "ruby") | .version')
1616

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

2122
# 3. MAKE RUBY AVAILABLE DURING LAUNCH

stacks/build-stack.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ RUN_IMAGE=${REPO_PREFIX}-run:${TAG}
6161
BUILD_IMAGE=${REPO_PREFIX}-build:${TAG}
6262

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

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

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

7373
echo
7474
echo "STACK BUILT!"

0 commit comments

Comments
 (0)