From 60736dbbc63f1b2b3d53a6f80536a7908af3b962 Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Tue, 22 Oct 2024 15:25:21 -0300 Subject: [PATCH] feat(cli): enforce build for linux/riscv64 platform since the target is always a Cartesi Machine (riscv64), cartesi build should enforce the docker build environment via --platform argument --- .changeset/big-ghosts-rescue.md | 5 +++++ apps/cli/src/builder/docker.ts | 2 ++ apps/cli/test/builder/data/Dockerfile.nonriscv | 2 -- apps/cli/test/builder/docker.test.ts | 3 +-- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/big-ghosts-rescue.md delete mode 100644 apps/cli/test/builder/data/Dockerfile.nonriscv 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..7dc63dbf 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", 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 b6c73bea..495fdf41 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(