Skip to content

Commit

Permalink
Merge pull request #162 from dappnode/tropicar/read-architecture-nati…
Browse files Browse the repository at this point in the history
…vely

Read architecture natively
  • Loading branch information
dapplion committed Apr 28, 2021
2 parents d7b02bb + ced8dcf commit 2a35b09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tasks/buildAndUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { buildWithBuildx } from "./buildWithBuildx";
import { buildWithCompose } from "./buildWithCompose";
import { parseArchitectures } from "../utils/parseArchitectures";
import { pruneCache } from "../utils/cache";
import { getArchitecture } from "../utils/getArchitecture";
import { getGitHead, getGitHeadIfAvailable } from "../utils/git";
import { fetchPinsWithBranchToDelete, getPinMetadata } from "../pinStrategy";
import { PinataPinManager } from "../providers/pinata/pinManager";
Expand Down Expand Up @@ -103,10 +104,15 @@ as ${releaseFilesDefaultNames.avatar} and then remove the 'manifest.avatar' prop

const architectures =
manifest.architectures && parseArchitectures(manifest.architectures);

// get the architecture of the machine where is executed the dappnodesdk
const hardwareArchitecture = getArchitecture();

const imagePathAmd = path.join(
buildDir,
getImagePath(name, version, "linux/amd64")
getImagePath(name, version, hardwareArchitecture)
);

const imagePathLegacy = path.join(
buildDir,
getLegacyImagePath(name, version)
Expand Down
17 changes: 17 additions & 0 deletions src/utils/getArchitecture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Architecture } from "../types";
import os from "os";

/**
* Returns the architecture of the host machine doing the build
*/
export function getArchitecture(): Architecture {
// 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 {
return "linux/amd64";
}
}

0 comments on commit 2a35b09

Please sign in to comment.