Skip to content

Commit

Permalink
feat(cli): enforce build for linux/riscv64 platform
Browse files Browse the repository at this point in the history
since the target is always a Cartesi Machine (riscv64), cartesi build
should enforce the docker build environment via --platform argument
  • Loading branch information
endersonmaia committed Oct 22, 2024
1 parent f84703a commit 60736db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-ghosts-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": patch
---

enforce build for linux/riscv64 platform
2 changes: 2 additions & 0 deletions apps/cli/src/builder/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const buildImage = async (options: ImageBuildOptions): Promise<string> => {
const args = [
"buildx",
"build",
"--platform",
"linux/riscv64",
"--file",
dockerfile,
"--load",
Expand Down
2 changes: 0 additions & 2 deletions apps/cli/test/builder/data/Dockerfile.nonriscv

This file was deleted.

3 changes: 1 addition & 2 deletions apps/cli/test/builder/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(

Check failure on line 44 in apps/cli/test/builder/docker.test.ts

View workflow job for this annotation

GitHub Actions / build

test/builder/docker.test.ts > when building with the docker builder > should fail a non-riscv image

AssertionError: expected [Function] to throw error including 'Expected riscv64' but got 'Command failed with exit code 1: dock…' - Expected + Received - Expected riscv64 + Command failed with exit code 1: docker image inspect 'debian:bookworm-slim' + + Error response from daemon: No such image: debian:bookworm-slim + + [] ❯ test/builder/docker.test.ts:44:9
Expand Down

0 comments on commit 60736db

Please sign in to comment.