Hi, I'm looking for a way to build an image from a dockerfile that is outside of the current dagger workspace. Using absolute path to the Dockerfile doesn't work, but I can read the Dockerfile content from python using that absolute path. For example:
import dagger
import anyio
async def build():
async with dagger.Connection() as client:
dockerfile_path = "/workspaces/dagger-importlib/Dockerfile"
workspace = client.host().directory(".")
ctr = (
client.pipeline("test")
.container()
.build(context=workspace, dockerfile=dockerfile_path)
.with_exec(["apk", "add", "curl"])
.with_exec(["curl", "https://dagger.io"])
)
output = await ctr.stdout()
print(output[:300])
if __name__ == "__main__":
anyio.run(build)
I'm not sure how dagger build function interact with the host machine, I expected it to run the build command like I do locally. If dealing with absolute path is not possible, is there a way to build from the file content instead? The dockerfile parameter currently only support a string of path to the dockerfile afaik