Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add start cmd for build in CLI [WIP]

Tomas Valenta31a17e172ed1
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index c6a19a690..1e1a6dd11 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -60,6 +60,10 @@ export const buildCommand = new commander.Command('build')
'-n, --name <template-name>',
'Specify sandbox template name. You can use the template name to start the sandbox with SDK. The template name must be lowercase and contain only letters, numbers, dashes and underscores',
)
+ .option(
+ '-c, --start-cmd <cmd>',
+ 'Specify command that will be executed when the sandbox is started',
+ )
.alias('bd')
.action(
async (
@@ -68,6 +72,7 @@ export const buildCommand = new commander.Command('build')
path?: string;
dockerfile?: string;
name?: string;
+ startCmd?: string;
},
) => {
try {
@@ -84,6 +89,7 @@ export const buildCommand = new commander.Command('build')
let envID = id
let dockerfile = opts.dockerfile
+ let startCmd = opts.startCmd
const root = getRoot(opts.path)
const configPath = getConfigPath(root)
@@ -105,7 +111,8 @@ export const buildCommand = new commander.Command('build')
)}`,
)
envID = config.id
- dockerfile = config.dockerfile
+ dockerfile = opts.dockerfile || config.dockerfile
+ startCmd = opts.startCmd || config.start_cmd
}
if (config && id && config.id !== id) {
@@ -165,6 +172,10 @@ export const buildCommand = new commander.Command('build')
body.append('alias', name)
}
+ if (startCmd) {
+ body.append('startCmd', startCmd)
+ }
+
const build = await buildTemplate(accessToken, body, envID)
console.log(
@@ -180,7 +191,8 @@ export const buildCommand = new commander.Command('build')
{
id: build.envID,
dockerfile: dockerfileRelativePath,
- name: name,
+ name,
+ start_cmd: startCmd,
},
true,
)
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index 2bd2f93b9..f0beacc55 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -17,6 +17,7 @@ export const configSchema = yup.object({
name: yup.string(),
id: yup.string().required(),
dockerfile: yup.string().required(),
+ start_cmd: yup.string(),
})
export type E2BConfig = yup.InferType<typeof configSchema>;