From deda62253e1c02e17d4ea9a87734e6c09c9866ac Mon Sep 17 00:00:00 2001 From: kjuulh Date: Mon, 13 Mar 2023 20:11:29 +0100 Subject: [PATCH] replication(issue-30): initial issue --- crates/dagger-sdk/examples/iss-30/main.rs | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 crates/dagger-sdk/examples/iss-30/main.rs diff --git a/crates/dagger-sdk/examples/iss-30/main.rs b/crates/dagger-sdk/examples/iss-30/main.rs new file mode 100644 index 0000000..9f7ce5c --- /dev/null +++ b/crates/dagger-sdk/examples/iss-30/main.rs @@ -0,0 +1,44 @@ +#![feature(async_closure)] + +use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOptsBuilder}; + +static DOCKER_FILES: [&str; 3] = ["Dockerfile", "Dockerfile.alpine", "Dockerfile.distroless"]; +static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"]; + +#[tokio::main] +async fn main() -> eyre::Result<()> { + let client = dagger_sdk::connect().await?; + + let context = client.host().directory_opts( + ".", + HostDirectoryOpts { + exclude: Some(vec!["target", "client/node_modules", "client/build"]), + include: None, + }, + ); + + for file in DOCKER_FILES { + for platform in PLATFORMS { + let ref_ = client + .container_opts( + QueryContainerOptsBuilder::default() + .platform(platform) + .build() + .unwrap(), + ) + .build_opts( + context.id().await?, + ContainerBuildOptsBuilder::default() + .dockerfile(file) + .build() + .unwrap(), + ) + .export("./test") + .await?; + + println!("published image to: {:#?}", ref_); + } + } + + Ok(()) +}