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

Builders and buildpacks for host platform arch #133

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
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