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

Support arm64 #233

Merged
merged 2 commits into from
Mar 21, 2024
Merged

Support arm64 #233

merged 2 commits into from
Mar 21, 2024

Conversation

runesoerensen
Copy link
Contributor

@runesoerensen runesoerensen commented Mar 13, 2024

This PR adds the linux/arm64 target in buildpack.toml.

For testing the buildpack, an arm64 compatible builder can be created locally (using the newly released heroku-24 base images (tested on an m1 Mac with Docker's containerd feature enabled), and a basic builder configuration file) - e.g. something like this:

builder-24/builder.toml:

description = "Heroku-24 (Ubuntu 24.04) builder sans buildpacks"

[stack]
id = "heroku-24"
build-image = "heroku/heroku:24-build.nightly"
run-image = "heroku/heroku:24.nightly"

[lifecycle]
version = "0.19.0"

Create the builder:

pack builder create heroku/builder:24 --config ./builder-24/builder.toml

Compile and package the CNBs:

cargo libcnb package

cargo libcnb package --target aarch64-unknown-linux-musl

To test that the x86_64 version still work as intended, we need to use the old builder (asheroku/builder:24 won't work for multi-arch locally):

pack build go-amd64-app \
--buildpack packaged/x86_64-unknown-linux-musl/debug/heroku_go \
--path buildpacks/go/tests/fixtures/basic_http_122 --builder heroku/builder:22

To test aarch64:

pack build go-arm64-app \
--buildpack packaged/aarch64-unknown-linux-musl/debug/heroku_go \
--path buildpacks/go/tests/fixtures/basic_http_122 --builder heroku/builder:24

Running the commands twice should reuse cached layers as usual. Another app can be used to verify cache invalidation, e.g.:

pack build go-arm64-app \
--buildpack packaged/aarch64-unknown-linux-musl/debug/heroku_go \
--path buildpacks/go/tests/fixtures/basic_http_119 --builder heroku/builder:24

This can also be tested with an integration test in buildpacks/go/tests/integration_tests.rs (and a similar test should be added when heroku/builder:24 is available in the registry):

#[test]
#[ignore = "integration test"]
fn test_go_arm64() {
    TestRunner::default().build(
        BuildConfig::new("heroku/builder:24", "tests/fixtures/basic_http_116")
            .target_triple("aarch64-unknown-linux-musl"),
        |ctx| {
            assert_contains!(
                ctx.pack_stdout,
                "Installing go1.16.15 (linux-aarch64) from https://go.dev/dl/go1.16.15.linux-arm64.tar.gz",
            );
        },
    );
}

See comment below for creating an arm64 builder on an amd64 host.

@runesoerensen runesoerensen changed the base branch from main to refactor-utility-functions March 13, 2024 14:37
@runesoerensen runesoerensen added enhancement New feature or request rust Pull requests that update Rust code labels Mar 13, 2024
@runesoerensen runesoerensen self-assigned this Mar 13, 2024
@runesoerensen runesoerensen mentioned this pull request Mar 13, 2024
@runesoerensen runesoerensen marked this pull request as ready for review March 13, 2024 14:53
@runesoerensen runesoerensen requested review from joshwlewis and a team as code owners March 13, 2024 14:53
Base automatically changed from refactor-utility-functions to main March 14, 2024 18:42
@runesoerensen runesoerensen force-pushed the support-arm64 branch 2 times, most recently from fc02403 to c66dc70 Compare March 18, 2024 22:02
@runesoerensen runesoerensen changed the base branch from main to prefer-artifact-over-version-in-layers March 18, 2024 22:21
@runesoerensen runesoerensen force-pushed the prefer-artifact-over-version-in-layers branch from f47ae36 to b0d0b4b Compare March 20, 2024 05:55
Base automatically changed from prefer-artifact-over-version-in-layers to main March 20, 2024 17:55
@edmorley edmorley removed the request for review from a team March 21, 2024 10:37
@joshwlewis
Copy link
Member

To test this, I had to modify your example steps. Since I'm on an Intel-based Mac, my builder.toml looked like this:

description = "Heroku-24 (Ubuntu 24.04) builder sans buildpacks"

[stack]
id = "heroku-24"
# Direct reference to heroku/heroku:24 arm64 variant image by sha
build-image = "heroku/heroku@sha256:860714147f7deb5540aada42db1028d88204bf1ba0ded8209663c5d4d55d423d"
# Direct reference to heroku/heroku:24-build arm64 variant image by sha
run-image = "heroku/heroku@sha256:ef63d62be65d145f7db1f11257691b294b5dcc302ffe14a33185884780572e1c"

[lifecycle]
version = "0.19.0"

But it worked, and that's awesome!

@joshwlewis
Copy link
Member

and a similar test should be added when heroku/builder:24 is available in the registry

Yes, definitely. Is this tracked somewhere so we don't forget?

@runesoerensen
Copy link
Contributor Author

and a similar test should be added when heroku/builder:24 is available in the registry

Yes, definitely. Is this tracked somewhere so we don't forget?

Yep, I just created an issue for it #239 :)

@runesoerensen runesoerensen merged commit a5964e5 into main Mar 21, 2024
4 checks passed
@runesoerensen runesoerensen deleted the support-arm64 branch March 21, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants