Hi,
I´m trying to pass build args starting from a Dockerfile that I have in my repo. Which is the equivalent code in Python from this https://docs.dagger.io/sdk/cue/966156/docker/#build-arguments ?
I tried to use this two functions, but I didn't figure out how to use them.
My code:
async def build_and_publish():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
src_id = await client.host().workdir("../").id()
# Read images file
with open('.dagger/images.json') as imgs_file:
images = json.load(imgs_file)['images']
for image in images:
print(f"Building {image['tag']}")
print(f"Dockerfile: {image['dockerfile']} ...")
container = (
client
.container()
)
# Split build args on newlines
build_args = image['build_args'].splitlines()
print(f"Build args: {build_args}")
container = (
container.with_default_args(build_args)
)
container = (
container
.build(src_id, image['dockerfile'])
)
print(f"Publishing {image['tag']}")
await container.publish(image['tag'])
``` Thanks in advance
The universe.dagger.io module is meant to provide higher level abstractions on top of core actions. Of these, the universe.dagger.io/docker package provides a general base for building and running docker images.