mount user settings in sandbox (#239)
This commit is contained in:
parent
7e8f379dfb
commit
a386841947
|
@ -9,9 +9,9 @@ import * as path from 'path';
|
||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
import { Config } from '@gemini-code/server';
|
import { Config } from '@gemini-code/server';
|
||||||
|
|
||||||
const SETTINGS_DIRECTORY_NAME = '.gemini';
|
export const SETTINGS_DIRECTORY_NAME = '.gemini';
|
||||||
const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
|
export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
|
||||||
const USER_SETTINGS_PATH = path.join(USER_SETTINGS_DIR, 'settings.json');
|
export const USER_SETTINGS_PATH = path.join(USER_SETTINGS_DIR, 'settings.json');
|
||||||
|
|
||||||
export enum SettingScope {
|
export enum SettingScope {
|
||||||
User = 'User',
|
User = 'User',
|
||||||
|
|
|
@ -9,6 +9,10 @@ import os from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { quote } from 'shell-quote';
|
import { quote } from 'shell-quote';
|
||||||
|
import {
|
||||||
|
USER_SETTINGS_DIR,
|
||||||
|
SETTINGS_DIRECTORY_NAME,
|
||||||
|
} from '../config/settings.js';
|
||||||
|
|
||||||
// node.js equivalent of scripts/sandbox_command.sh
|
// node.js equivalent of scripts/sandbox_command.sh
|
||||||
export function sandbox_command(): string {
|
export function sandbox_command(): string {
|
||||||
|
@ -98,6 +102,21 @@ export async function start_sandbox(sandbox: string) {
|
||||||
// mount current directory as ${workdir} inside container
|
// mount current directory as ${workdir} inside container
|
||||||
args.push('--volume', `${process.cwd()}:${workdir}`);
|
args.push('--volume', `${process.cwd()}:${workdir}`);
|
||||||
|
|
||||||
|
// mount user settings directory inside container, after creating if missing
|
||||||
|
// note user/home changes inside sandbox and we mount at BOTH paths for consistency
|
||||||
|
const userSettingsDirOnHost = USER_SETTINGS_DIR;
|
||||||
|
const userSettingsDirInSandbox = `/home/node/${SETTINGS_DIRECTORY_NAME}`;
|
||||||
|
if (!fs.existsSync(userSettingsDirOnHost)) {
|
||||||
|
fs.mkdirSync(userSettingsDirOnHost);
|
||||||
|
}
|
||||||
|
args.push('--volume', `${userSettingsDirOnHost}:${userSettingsDirOnHost}`);
|
||||||
|
if (userSettingsDirInSandbox !== userSettingsDirOnHost) {
|
||||||
|
args.push(
|
||||||
|
'--volume',
|
||||||
|
`${userSettingsDirOnHost}:${userSettingsDirInSandbox}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// mount os.tmpdir() as /tmp inside container
|
// mount os.tmpdir() as /tmp inside container
|
||||||
args.push('--volume', `${os.tmpdir()}:/tmp`);
|
args.push('--volume', `${os.tmpdir()}:/tmp`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue