Use nested paths for host mounts
This commit is contained in:
parent
3d41e3de29
commit
3b21a2afd1
16
src/vm.ts
16
src/vm.ts
|
|
@ -16,10 +16,10 @@ export function containerPath(hostPath: string): string {
|
|||
return "/sandlot" + hostPath.slice(`${home}/.sandlot`.length)
|
||||
}
|
||||
if (hostPath.startsWith(`${home}/dev`)) {
|
||||
return "/host" + hostPath.slice(`${home}/dev`.length)
|
||||
return "/host/dev" + hostPath.slice(`${home}/dev`.length)
|
||||
}
|
||||
if (hostPath.startsWith(`${home}/Code`)) {
|
||||
return "/host-code" + hostPath.slice(`${home}/Code`.length)
|
||||
return "/host/Code" + hostPath.slice(`${home}/Code`.length)
|
||||
}
|
||||
return hostPath
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ async function hostMounts(home: string): Promise<{ dev: boolean; code: boolean }
|
|||
async function createContainer(home: string): Promise<void> {
|
||||
const mounts = await hostMounts(home)
|
||||
const args = ["container", "run", "-d", "--name", CONTAINER_NAME, "-m", "4G"]
|
||||
if (mounts.dev) args.push("--mount", `type=bind,source=${home}/dev,target=/host,readonly`)
|
||||
if (mounts.code) args.push("--mount", `type=bind,source=${home}/Code,target=/host-code,readonly`)
|
||||
if (mounts.dev) args.push("--mount", `type=bind,source=${home}/dev,target=/host/dev,readonly`)
|
||||
if (mounts.code) args.push("--mount", `type=bind,source=${home}/Code,target=/host/Code,readonly`)
|
||||
args.push("-v", `${home}/.sandlot:/sandlot`, "ubuntu:24.04", "sleep", "infinity")
|
||||
const result = await $`${args}`.nothrow().quiet()
|
||||
if (result.exitCode !== 0) {
|
||||
|
|
@ -82,8 +82,8 @@ async function installPackages(cached: boolean): Promise<void> {
|
|||
async function createHostSymlinks(home: string): Promise<void> {
|
||||
const mounts = await hostMounts(home)
|
||||
const cmds = [`mkdir -p '${home}'`, `ln -s /sandlot '${home}/.sandlot'`]
|
||||
if (mounts.dev) cmds.push(`ln -s /host '${home}/dev'`)
|
||||
if (mounts.code) cmds.push(`ln -s /host-code '${home}/Code'`)
|
||||
if (mounts.dev) cmds.push(`ln -s /host/dev '${home}/dev'`)
|
||||
if (mounts.code) cmds.push(`ln -s /host/Code '${home}/Code'`)
|
||||
await run(
|
||||
$`container exec ${CONTAINER_NAME} bash -c ${cmds.join(" && ")}`,
|
||||
"Symlink creation")
|
||||
|
|
@ -269,8 +269,8 @@ export async function claude(workdir: string, opts?: { prompt?: string; print?:
|
|||
"You are running inside a sandlot container (Apple Container, ubuntu:24.04).",
|
||||
`Your working directory is ${cwd}, a git worktree managed by sandlot.`,
|
||||
]
|
||||
if (mounts.dev) systemPromptLines.push("The host's ~/dev is mounted read-only at /host.")
|
||||
if (mounts.code) systemPromptLines.push("The host's ~/Code is mounted read-only at /host-code.")
|
||||
if (mounts.dev) systemPromptLines.push("The host's ~/dev is mounted read-only at /host/dev.")
|
||||
if (mounts.code) systemPromptLines.push("The host's ~/Code is mounted read-only at /host/Code.")
|
||||
systemPromptLines.push(
|
||||
"The host's ~/.sandlot is mounted at /sandlot.",
|
||||
"Bun is installed at ~/.local/bin/bun. Use bun instead of node/npm.",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user