mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-12-22 18:33:30 +01:00
replication(issue-30): initial issue
This commit is contained in:
parent
44fa0240f8
commit
f67928155f
44
crates/dagger-sdk/examples/iss-30/main.rs
Normal file
44
crates/dagger-sdk/examples/iss-30/main.rs
Normal file
@ -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(())
|
||||
}
|
Loading…
Reference in New Issue
Block a user