Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Always include dockerfile (#295)

Jakub Novák783a15d18721
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index 427a58545..db668bd99 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -124,6 +124,7 @@ export const buildCommand = new commander.Command('build')
const filePaths = await getFiles(root, {
respectGitignore: false,
respectDockerignore: true,
+ overrideIgnoreFor: [dockerfile || defaultDockerfileName],
})
if (newName && config?.template_name && newName !== config?.template_name) {
diff --git a/packages/cli/src/utils/filesystem.ts b/packages/cli/src/utils/filesystem.ts
index e24bd8e10..3436c4045 100644
--- a/packages/cli/src/utils/filesystem.ts
+++ b/packages/cli/src/utils/filesystem.ts
@@ -16,6 +16,7 @@ const walk = util.promisify(fsWalk.walk)
* @param opts.name - If specified, only a file with this name will be returned.
* @param opts.respectGitignore - If true, files that are ignored by .gitignore will be excluded.
* @param opts.respectDockerignore - If true, files that are ignored by .dockerignore will be excluded.
+ * @param opts.overrideIgnoreFor - If specified, files that should be ignored will be still included if they match this list.
*/
export async function getFiles(
rootPath: string,
@@ -24,6 +25,7 @@ export async function getFiles(
name?: string;
respectGitignore?: boolean;
respectDockerignore?: boolean;
+ overrideIgnoreFor?: string[];
},
) {
let gitignore: gitIgnore.Ignore | undefined
@@ -63,7 +65,7 @@ export async function getFiles(
stats: true,
})
- return await Promise.all(
+ const files = await Promise.all(
entries.map(async (e) => {
return {
path: e.path as string,
@@ -72,6 +74,21 @@ export async function getFiles(
}
}),
)
+
+ if (opts?.overrideIgnoreFor) {
+ for (const override of opts.overrideIgnoreFor) {
+ const overridePath = path.join(rootPath, override)
+ if (files.map(file => file.path).indexOf(overridePath) === -1 && fs.existsSync(overridePath)) {
+ files.push({
+ path: overridePath,
+ rootPath: path.join('/', override),
+ name: path.basename(overridePath),
+ })
+ }
+ }
+ }
+
+ return files
}
export function getRoot(templatePath?: string) {