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

Fix AMD build on Mac #444

Merged
merged 2 commits into from
Jul 23, 2024
Merged
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
3 changes: 2 additions & 1 deletion src/tasks/buildAndUpload/getBuildTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { buildWithBuildx } from "./buildWithBuildx.js";
import { buildWithCompose } from "./buildWithCompose.js";
import { Architecture, defaultArch } from "@dappnode/types";
import { getImageFileName } from "../../utils/getImageFileName.js";
import { getOsArchitecture } from "../../utils/getArchitecture.js";

/**
* The naming scheme for multiarch exported images must be
Expand Down Expand Up @@ -57,7 +58,7 @@ function createBuildTask({
const { manifest, releaseDir, images, compose } = variantSpecs;
const { name, version } = manifest;
const buildFn =
architecture === defaultArch ? buildWithCompose : buildWithBuildx;
architecture === getOsArchitecture() ? buildWithCompose : buildWithBuildx;

const destPath = getImagePath({
releaseDir,
Expand Down
6 changes: 4 additions & 2 deletions src/utils/getArchitecture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { Architecture } from "@dappnode/types";
/**
* Returns the architecture of the host machine doing the build
*/
export function getArchitecture(): Architecture {
export function getOsArchitecture(): Architecture | "unsupported" {
// Returns the operating system CPU architecture for which the Node.js binary was compiled.
const arch = os.arch();

// TODO: DAppNode Packages are run in Linux-based systems. This solves the edge case when building in ARM
if (arch === "arm64") {
return "linux/arm64";
} else {
} else if (arch === "x64") {
return "linux/amd64";
} else {
return "unsupported";
}
}
3 changes: 1 addition & 2 deletions src/utils/parseArchitectures.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Architecture, architectures } from "@dappnode/types";
import { getArchitecture } from "./getArchitecture.js";

/**
*
* @param rawArchs
* @returns
*/
export function parseArchitectures({
rawArchs = [getArchitecture()]
rawArchs = ["linux/amd64"]
}: {
rawArchs?: Architecture[];
}): Architecture[] {
Expand Down
Loading