This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replication(issue-30): initial issue
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} |