2023-02-19 15:24:37 +01:00
|
|
|
use dagger_sdk::HostDirectoryOpts;
|
2023-02-17 15:47:12 +01:00
|
|
|
|
2023-02-19 21:37:54 +01:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> eyre::Result<()> {
|
2023-02-19 15:24:37 +01:00
|
|
|
let client = dagger_sdk::connect()?;
|
2023-02-17 15:47:12 +01:00
|
|
|
|
2023-02-19 17:43:12 +01:00
|
|
|
let host_source_dir = client.host().directory_opts(
|
2023-02-19 17:21:40 +01:00
|
|
|
"examples/build-the-application/app",
|
2023-02-19 17:49:22 +01:00
|
|
|
HostDirectoryOpts {
|
2023-02-17 15:47:12 +01:00
|
|
|
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
|
|
|
include: None,
|
2023-02-19 17:49:22 +01:00
|
|
|
},
|
2023-02-17 15:47:12 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
let source = client
|
2023-02-19 17:43:12 +01:00
|
|
|
.container()
|
2023-02-19 17:21:40 +01:00
|
|
|
.from("node:16")
|
2023-02-19 21:37:54 +01:00
|
|
|
.with_mounted_directory("/src", host_source_dir.id().await?);
|
2023-02-17 15:47:12 +01:00
|
|
|
|
|
|
|
let runner = source
|
2023-02-19 17:21:40 +01:00
|
|
|
.with_workdir("/src")
|
2023-02-19 17:43:12 +01:00
|
|
|
.with_exec(vec!["npm", "install"]);
|
2023-02-19 17:21:40 +01:00
|
|
|
|
2023-02-19 17:43:12 +01:00
|
|
|
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
|
2023-02-17 15:47:12 +01:00
|
|
|
|
|
|
|
let build_dir = test
|
2023-02-19 17:43:12 +01:00
|
|
|
.with_exec(vec!["npm", "run", "build"])
|
2023-02-19 17:21:40 +01:00
|
|
|
.directory("./build");
|
2023-02-17 15:47:12 +01:00
|
|
|
|
2023-02-19 17:21:40 +01:00
|
|
|
let _ = build_dir.export("./build");
|
2023-02-17 15:47:12 +01:00
|
|
|
|
2023-02-19 21:37:54 +01:00
|
|
|
let entries = build_dir.entries().await;
|
2023-02-17 15:47:12 +01:00
|
|
|
|
|
|
|
println!("build dir contents: \n {:?}", entries);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|