Skip to content

Commit

Permalink
Handle unsupported arch
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Jul 23, 2024
1 parent f788a0e commit 5742aeb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tasks/buildAndUpload/getBuildTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +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 { getArchitecture } from "../../utils/getArchitecture.js";
import { getOsArchitecture } from "../../utils/getArchitecture.js";

/**
* The naming scheme for multiarch exported images must be
Expand Down Expand Up @@ -58,7 +58,7 @@ function createBuildTask({
const { manifest, releaseDir, images, compose } = variantSpecs;
const { name, version } = manifest;
const buildFn =
architecture === getArchitecture() ? 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

0 comments on commit 5742aeb

Please sign in to comment.