Hello,
Is there a way to pass secret, env vars or secrets to the function build with a Dockerfile ?
It seems the build command does take any (mounted) secret, file or env var declared before the method build.
For instance to pass a secret to a build (possible via --mount=secret in docker)
async def build_module(directory: str):
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
context_dir = client.host().directory(f"./{directory}/")
root_dir = client.host().directory(".")
local_settings = root_dir.directory("./config/").file("local_settings.json").secret()
python = (
client.container()
.with_mounted_secret(source=local_settings,path="/config/local_settings.json")
.build(context=context_dir,dockerfile="Dockerfile")
.with_exec("python","--version")
)
# execute
stdout = await python.stdout()
The code does not work, as build probably reset the previous container to start a new one from scratch.
Thanks.