Skip to content

Commit

Permalink
Get sindri x circomspect working.
Browse files Browse the repository at this point in the history
  • Loading branch information
sangaline committed Feb 23, 2024
1 parent b60c0fc commit 5ba8fc3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- socat-docker-bridge
environment:
- DOCKER_HOST=tcp://localhost:2375
- SINDRI_DEVELOPMENT_HOST_ROOT=${PWD}
init: true
network_mode: host
extra_hosts:
Expand Down
23 changes: 22 additions & 1 deletion src/cli/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ const circomspectCommand = new Command()
return process.exit(1);
}

// Remap the root directory to its location on the host system when running in development mode.
let mountDirectory: string = rootDirectory;
if (process.env.SINDRI_DEVELOPMENT_HOST_ROOT) {
if (rootDirectory === "/sindri" || rootDirectory.startsWith("/sindri/")) {
mountDirectory = rootDirectory.replace(
"/sindri",
process.env.SINDRI_DEVELOPMENT_HOST_ROOT,
);
sindri.logger.debug(
`Remapped "${rootDirectory}" to "${mountDirectory}" for bind mount on the Docker host.`,
);
} else {
sindri.logger.fatal(
`The root directory path "${rootDirectory}" must be under "/sindri/"` +
'when using "SINDRI_DEVELOPMENT_HOST_ROOT".',
);
return process.exit(1);
}
}

// Run circomspect with the project root mounted and pipe the output to stdout.
let status: number;
try {
Expand All @@ -59,7 +79,7 @@ const circomspectCommand = new Command()
process.stdout,
{
HostConfig: {
Binds: [`${rootDirectory}:/sindri`],
Binds: [`${mountDirectory}:/sindri`],
},
},
(error, data) => {
Expand Down Expand Up @@ -102,6 +122,7 @@ export const execCommand = new Command()
`using the current directory as the project root.`,
);
}
rootDirectory = path.normalize(path.resolve(rootDirectory));

// Check that docker is installed.
docker = new Docker();
Expand Down

0 comments on commit 5ba8fc3

Please sign in to comment.