From 9ba71ea3e2b97dd3a316203093fdc5f8d491ebf3 Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Tue, 12 Mar 2024 14:47:05 +0000 Subject: [PATCH] Build multi arch binaries and add targets --- .gitignore | 1 + buildpack.toml | 9 +++++++++ scripts/build.sh | 16 ++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 592c46e..4242244 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # limitations under the License. bin/ +linux/ dependencies/ package/ scratch/ diff --git a/buildpack.toml b/buildpack.toml index 9a21444..ff558b2 100644 --- a/buildpack.toml +++ b/buildpack.toml @@ -27,6 +27,15 @@ api = "0.7" type = "Apache-2.0" uri = "https://github.com/paketo-buildpacks/procfile/blob/main/LICENSE" + +[[targets]] +os = "linux" +arch = "amd64" + +[[targets]] +os = "linux" +arch = "arm64" + [metadata] include-files = ["LICENSE", "NOTICE", "README.md", "bin/build", "bin/detect", "bin/main", "bin/build.exe", "bin/detect.exe", "bin/main.exe", "buildpack.toml"] pre-package = "scripts/build.sh" diff --git a/scripts/build.sh b/scripts/build.sh index 38c5ff1..cf8413f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,18 +2,18 @@ set -euo pipefail -GOOS="linux" go build -ldflags='-s -w' -o bin/main github.com/paketo-buildpacks/procfile/v5/cmd/main -GOOS="windows" GOARCH="amd64" go build -ldflags='-s -w' -o bin/main.exe github.com/paketo-buildpacks/procfile/v5/cmd/main +GOOS="linux" go build -ldflags='-s -w' -o linux/amd64/bin/main github.com/paketo-buildpacks/procfile/v5/cmd/main +GOOS="linux" GOARCH="arm64" go build -ldflags='-s -w' -o linux/arm64/bin/main github.com/paketo-buildpacks/procfile/v5/cmd/main if [ "${STRIP:-false}" != "false" ]; then - strip bin/main bin/main.exe + strip linux/amd64/bin/main linux/arm64/bin/main fi if [ "${COMPRESS:-none}" != "none" ]; then - $COMPRESS bin/main bin/main.exe + $COMPRESS linux/amd64/bin/main linux/arm64/bin/main fi -ln -fs main bin/build -ln -fs main bin/detect -ln -fs main.exe bin/build.exe -ln -fs main.exe bin/detect.exe +ln -fs main linux/amd64/bin/build +ln -fs main linux/arm64/bin/build +ln -fs main linux/amd64/bin/detect +ln -fs main linux/arm64/bin/detect