diff --git a/.changeset/big-ghosts-rescue.md b/.changeset/big-ghosts-rescue.md new file mode 100644 index 00000000..4794ee5b --- /dev/null +++ b/.changeset/big-ghosts-rescue.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +enforce build for linux/riscv64 platform diff --git a/apps/cli/src/builder/docker.ts b/apps/cli/src/builder/docker.ts index 98826482..85859a00 100644 --- a/apps/cli/src/builder/docker.ts +++ b/apps/cli/src/builder/docker.ts @@ -26,6 +26,8 @@ const buildImage = async (options: ImageBuildOptions): Promise => { const args = [ "buildx", "build", + "--platform", + "linux/riscv64", "--file", dockerfile, "--load", @@ -89,7 +91,13 @@ export const build = async ( const filename = `${name}.${format}`; // use pre-existing image or build docker image - const image = drive.image || (await buildImage(drive)); + let image: string; + if (drive.image) { + image = drive.image; + await execa("docker", ["image", "pull", image]); + } else { + image = await buildImage(drive); + } // get image info const imageInfo = await getImageInfo(image); diff --git a/apps/cli/test/builder/data/Dockerfile.nonriscv b/apps/cli/test/builder/data/Dockerfile.nonriscv deleted file mode 100644 index 95ea117f..00000000 --- a/apps/cli/test/builder/data/Dockerfile.nonriscv +++ /dev/null @@ -1,2 +0,0 @@ -FROM scratch -ADD ./file1 . diff --git a/apps/cli/test/builder/docker.test.ts b/apps/cli/test/builder/docker.test.ts index 373faa91..3c8ded34 100644 --- a/apps/cli/test/builder/docker.test.ts +++ b/apps/cli/test/builder/docker.test.ts @@ -35,11 +35,10 @@ describe("when building with the docker builder", () => { const drive: DockerDriveConfig = { builder: "docker", context: path.join(__dirname, "data"), - dockerfile: path.join(__dirname, "data", "Dockerfile.nonriscv"), extraSize: 0, format: "ext2", tags: [], - image: undefined, + image: "debian:bookworm-slim", target: undefined, }; await expect(build("root", drive, image, destination)).rejects.toThrow(