Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: enforce build for linux/riscv64 platform #73

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
tuler marked this conversation as resolved.
Show resolved Hide resolved
---

enforce build for linux/riscv64 platform
10 changes: 9 additions & 1 deletion 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 Expand Up @@ -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);
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(
Expand Down
Loading