Skip to content

armgit / E2B

Public Imported from GitHub
0

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

fix: set correct Dockerfile user workdir defaults (#941)

Jakub Dobryf12291272d7e
diff --git a/.changeset/tiny-lies-wink.md b/.changeset/tiny-lies-wink.md
new file mode 100644
index 000000000..7937afda8
--- /dev/null
+++ b/.changeset/tiny-lies-wink.md
@@ -0,0 +1,7 @@
+---
+'@e2b/python-sdk': patch
+'e2b': patch
+'@e2b/cli': patch
+---
+
+set correct Docker user workdir defaults
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py
index 64fd36d11..618269951 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py
index 89c6fbe6d..0ca197506 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/template.py
index 71338e310..591347a9c 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/template.py
@@ -3,6 +3,8 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("python:3.11-slim")
+ .set_user("root")
+ .set_workdir("/")
.run_cmd("apt-get update && apt-get install -y gcc g++ make libpq-dev && rm -rf /var/lib/apt/lists/*")
.set_envs({
"PYTHONDONTWRITEBYTECODE": "1",
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py
index 690070721..a2862153c 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="complex-python-app-dev",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py
index c24b743f1..56bc070ca 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="complex-python-app",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/template.py
index 94a28b5b4..11388c0a0 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/template.py
@@ -3,6 +3,8 @@ from e2b import Template
template = (
Template()
.from_image("python:3.11-slim")
+ .set_user("root")
+ .set_workdir("/")
.run_cmd("apt-get update && apt-get install -y gcc g++ make libpq-dev && rm -rf /var/lib/apt/lists/*")
.set_envs({
"PYTHONDONTWRITEBYTECODE": "1",
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts
index ab0970e38..6ee102d29 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts
index f5d7df411..9989c4544 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/template.ts
index 1bd1927dd..9d116ace4 100644
--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/template.ts
@@ -2,6 +2,8 @@ import { Template } from 'e2b'
export const template = Template()
.fromImage('python:3.11-slim')
+ .setUser('root')
+ .setWorkdir('/')
.runCmd('apt-get update && apt-get install -y gcc g++ make libpq-dev && rm -rf /var/lib/apt/lists/*')
.setEnvs({
'PYTHONDONTWRITEBYTECODE': '1',
@@ -15,4 +17,4 @@ export const template = Template()
.setUser('appuser')
.setUser('root')
.setWorkdir('/home/user')
- .setStartCmd('gunicorn --bind 0.0.0.0:8000 app:application', 'sleep 20')
+ .setStartCmd('gunicorn --bind 0.0.0.0:8000 app:application', 'sleep 20')
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py
index 4f84e88b3..900ec5f67 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py
index c9623f9f7..677ef1332 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/template.py
index 61e8fc604..be38cc4f1 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/template.py
@@ -3,6 +3,8 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("alpine:latest")
+ .set_user("root")
+ .set_workdir("/")
.copy("package.json", "/app/")
.copy("src/index.js", "./src/")
.copy("config.json", "/etc/app/config.json")
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py
index bfa5130c4..a16d67817 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="copy-test-dev",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py
index d7e50a8e4..05d447e33 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="copy-test",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/template.py
index 83a3694c3..d577098ea 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/template.py
@@ -3,6 +3,8 @@ from e2b import Template
template = (
Template()
.from_image("alpine:latest")
+ .set_user("root")
+ .set_workdir("/")
.copy("package.json", "/app/")
.copy("src/index.js", "./src/")
.copy("config.json", "/etc/app/config.json")
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts
index e1322523a..6cc5a2f7b 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts
index ea6273eef..57d99a181 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/template.ts
index a4fffac47..91cea36ad 100644
--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/template.ts
@@ -2,6 +2,8 @@ import { Template } from 'e2b'
export const template = Template()
.fromImage('alpine:latest')
+ .setUser('root')
+ .setWorkdir('/')
.copy('package.json', '/app/')
.copy('src/index.js', './src/')
- .copy('config.json', '/etc/app/config.json')
+ .copy('config.json', '/etc/app/config.json')
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py
index 99799c049..9cff4ef28 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py
index 8172c99da..3d996a97d 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/template.py
index 3146ae513..8d06c8e83 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/template.py
@@ -3,6 +3,8 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("node:18")
+ .set_user("root")
+ .set_workdir("/")
.set_workdir("/app")
.copy("server.js", ".")
.set_user("root")
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py
index eff404af6..7c84ccb90 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="custom-app-dev",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py
index 207bf3283..f4195c083 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="custom-app",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/template.py
index 4ce6a52d4..cace62b03 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/template.py
@@ -3,6 +3,8 @@ from e2b import Template
template = (
Template()
.from_image("node:18")
+ .set_user("root")
+ .set_workdir("/")
.set_workdir("/app")
.copy("server.js", ".")
.set_user("root")
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts
index 745ab073b..5eab3397b 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts
index e40611794..4f3085568 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/template.ts
index cccc51f8b..2fcd22b27 100644
--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/template.ts
@@ -2,8 +2,10 @@ import { Template } from 'e2b'
export const template = Template()
.fromImage('node:18')
+ .setUser('root')
+ .setWorkdir('/')
.setWorkdir('/app')
.copy('server.js', '.')
.setUser('root')
.setWorkdir('/home/user')
- .setStartCmd('node server.js', 'curl -f http://localhost:3000/health || exit 1')
+ .setStartCmd('node server.js', 'curl -f http://localhost:3000/health || exit 1')
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py
index c08181d51..20c9b044d 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py
index e3b2c97e4..14386413a 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/template.py
index 46dc7734c..e87b61a01 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/template.py
@@ -3,4 +3,6 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("ubuntu:latest")
-)
+ .set_user("root")
+ .set_workdir("/")
+)
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py
index 2d71c1c19..58241df23 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="minimal-template-dev",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py
index 0e79d75d4..39ce1a568 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="minimal-template",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/template.py
index d8845e053..fa222a559 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/template.py
@@ -3,4 +3,6 @@ from e2b import Template
template = (
Template()
.from_image("ubuntu:latest")
-)
+ .set_user("root")
+ .set_workdir("/")
+)
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts
index 8c4f9cc33..cfba1c003 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts
index 758d9dce0..4c6eacaf3 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/template.ts
index fa4fa0d98..11fabe948 100644
--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/template.ts
@@ -2,3 +2,5 @@ import { Template } from 'e2b'
export const template = Template()
.fromImage('ubuntu:latest')
+ .setUser('root')
+ .setWorkdir('/')
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py
index 33af3d7d2..8d71582d8 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py
index ebe798da7..2926f9fab 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/template.py
index 9849311f0..9edefaa7f 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/template.py
@@ -3,4 +3,4 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("my-custom-image")
-)
+)
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py
index 59fffa7d9..ec17a4ac5 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="multi-stage-dev",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py
index fc53b3003..8491ec32c 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="multi-stage",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/template.py
index c1efd3d69..ce79dd098 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/template.py
@@ -3,4 +3,4 @@ from e2b import Template
template = (
Template()
.from_image("my-custom-image")
-)
+)
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts
index 0fdecd176..7992e5d0f 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts
index 8dd3e5781..133492953 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/template.ts
index 6df1999cb..c69e38b68 100644
--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/template.ts
@@ -1,4 +1,4 @@
import { Template } from 'e2b'
export const template = Template()
- .fromImage('my-custom-image')
+ .fromImage('my-custom-image')
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py
index 3cb18ece4..3fb69fa7d 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py
index 37cd47d06..c1f15eaa5 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py
@@ -12,4 +12,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/template.py
index beb147852..334bc86c7 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/template.py
@@ -3,6 +3,8 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("node:18")
+ .set_user("root")
+ .set_workdir("/")
.set_envs({
"NODE_ENV": "production",
})
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py
index 63301bafd..e53859b94 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="env-test-dev",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py
index 621445029..aa968c267 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py
@@ -7,4 +7,4 @@ if __name__ == "__main__":
template,
alias="env-test",
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/template.py
index 068644bb4..d6d01c9f3 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/template.py
@@ -3,6 +3,8 @@ from e2b import Template
template = (
Template()
.from_image("node:18")
+ .set_user("root")
+ .set_workdir("/")
.set_envs({
"NODE_ENV": "production",
})
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts
index 10c0e292e..2fab51c19 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts
index df7f44057..f2e148103 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts
@@ -8,4 +8,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/template.ts
index 225074837..e5cdb0d5d 100644
--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/template.ts
@@ -2,6 +2,8 @@ import { Template } from 'e2b'
export const template = Template()
.fromImage('node:18')
+ .setUser('root')
+ .setWorkdir('/')
.setEnvs({
'NODE_ENV': 'production',
})
@@ -16,4 +18,4 @@ export const template = Template()
.setEnvs({
'SINGLE_VAR': 'single_value',
})
- .setWorkdir('/app')
+ .setWorkdir('/app')
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py
index c0cd96d96..4cc63b473 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py
@@ -14,4 +14,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py
index 8da80c6e4..619683495 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py
@@ -14,4 +14,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
+ asyncio.run(main())
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/template.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/template.py
index dcae70878..a42286b40 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/template.py
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/template.py
@@ -3,6 +3,8 @@ from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("python:3.11")
+ .set_user("root")
+ .set_workdir("/")
.set_workdir("/app")
.run_cmd("pip install --upgrade pip")
.run_cmd("pip install -r requirements.txt")
@@ -12,4 +14,4 @@ template = (
.set_user("root")
.set_workdir("/home/user")
.set_start_cmd("node server.js", "sleep 20")
-)
+)
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py
index 2241a6c2d..7c81d9b2b 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py
@@ -9,4 +9,4 @@ if __name__ == "__main__":
cpu_count=2,
memory_mb=1024,
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py
index 8fd2e2ad7..41c44139a 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py
@@ -9,4 +9,4 @@ if __name__ == "__main__":
cpu_count=2,
memory_mb=1024,
on_build_logs=default_build_logger(),
- )
+ )
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/template.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/template.py
index ba2f46083..5c8fb54db 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/template.py
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/template.py
@@ -3,6 +3,8 @@ from e2b import Template
template = (
Template()
.from_image("python:3.11")
+ .set_user("root")
+ .set_workdir("/")
.set_workdir("/app")
.run_cmd("pip install --upgrade pip")
.run_cmd("pip install -r requirements.txt")
@@ -12,4 +14,4 @@ template = (
.set_user("root")
.set_workdir("/home/user")
.set_start_cmd("node server.js", "sleep 20")
-)
+)
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts
index 5872ff5ff..8c13375f4 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts
@@ -10,4 +10,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts
index ed353067a..74677ba71 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts
@@ -10,4 +10,4 @@ async function main() {
});
}
-main().catch(console.error);
+main().catch(console.error);
\ No newline at end of file
diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/template.ts b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/template.ts
index 9e2dc7c90..3c298c427 100644
--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/template.ts
+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/template.ts
@@ -2,6 +2,8 @@ import { Template } from 'e2b'
export const template = Template()
.fromImage('python:3.11')
+ .setUser('root')
+ .setWorkdir('/')
.setWorkdir('/app')
.runCmd('pip install --upgrade pip')
.runCmd('pip install -r requirements.txt')
@@ -10,4 +12,4 @@ export const template = Template()
})
.setUser('root')
.setWorkdir('/home/user')
- .setStartCmd('node server.js', 'sleep 20')
+ .setStartCmd('node server.js', 'sleep 20')
\ No newline at end of file
diff --git a/packages/js-sdk/src/template/dockerfileParser.ts b/packages/js-sdk/src/template/dockerfileParser.ts
index 551f5e3ae..ccf64eb29 100644
--- a/packages/js-sdk/src/template/dockerfileParser.ts
+++ b/packages/js-sdk/src/template/dockerfileParser.ts
@@ -1,4 +1,4 @@
-import { CopyItem, Instruction } from './types'
+import { CopyItem } from './types'
import {
Argument,
DockerfileParser,
@@ -9,7 +9,6 @@ import { ReadyCmd, waitForTimeout } from './readycmd'
export interface DockerfileParseResult {
baseImage: string
- instructions: Instruction[]
}
interface DockerfileFinalParserInterface {}
@@ -91,7 +90,9 @@ export function parseDockerfile(
baseImage = argumentsData[0].getValue()
}
- const resultInstructions: Instruction[] = []
+ // Set the user and workdir to the Docker defaults
+ templateBuilder.setUser('root')
+ templateBuilder.setWorkdir('/')
// Process all other instructions
for (const instruction of instructions) {
@@ -145,7 +146,6 @@ export function parseDockerfile(
return {
baseImage,
- instructions: resultInstructions,
}
}
diff --git a/packages/python-sdk/e2b/template/dockerfile_parser.py b/packages/python-sdk/e2b/template/dockerfile_parser.py
index 558bdadbf..c1d27be0d 100644
--- a/packages/python-sdk/e2b/template/dockerfile_parser.py
+++ b/packages/python-sdk/e2b/template/dockerfile_parser.py
@@ -104,6 +104,10 @@ def parse_dockerfile(
if " as " in base_image.lower():
base_image = base_image.split(" as ")[0].strip()
+ # Set the user and workdir to the Docker defaults
+ template_builder.set_user("root")
+ template_builder.set_workdir("/")
+
# Process all other instructions
for instruction_data in dfp.structure:
instruction = instruction_data["instruction"]