This is what I ran:
import sys
import anyio
import dagger
import os
async def main():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
deploy_image = os.getenv("PYTHON_IMAGE", "python:3.10-slim")
src = client.host().directory(".")
build = (
client.container().pipeline("build")
.from_(deploy_image)
.with_mounted_cache("/root/.cache", client.cache_volume("pip"))
.with_mounted_directory("/src", src)
.with_workdir("/src")
.with_exec(["pip", "install", "."])
)
deploy = (
client.container()
.pipeline("deploy")
.from_(deploy_image)
.with_env_variable("PYTHONPATH", "/")
.with_directory(
"/usr/local/lib/python3.10/site-packages",
build.directory("/usr/local/lib/python3.10/site-packages"),
)
.with_exposed_port(8080)
.with_default_args(
args=[
"whoami",
]
)
)
await deploy.export("/tmp/kea-netbox-helper.tar")
if __name__ == "__main__":
anyio.run(main)