use std::{path::PathBuf, sync::Arc}; use dagger_rust::build::{RustVersion, SlimImage}; use dagger_sdk::Query; #[tokio::main] async fn main() -> eyre::Result<()> { let client = dagger_sdk::connect().await?; let agent = build_container(client.clone(), "churn-agent").await?; let agent = agent .with_exec(vec!["churn-agent", "daemon", "--host", "0.0.0.0:3000"]) .with_exposed_port(3000); let cli = build_container(client.clone(), "churn").await?; let server = build_container(client.clone(), "churn-server").await?; let server = server .with_exec(vec!["churn-server", "serve", "--host", "0.0.0.0:3000"]) .with_exposed_port(3000); let churning = cli .with_service_binding("churn-agent", agent.id().await?) .with_service_binding("churn-server", server.id().await?) .with_exec(vec![ "churn", "health", "--server", "http://churn-server:3000", "--agent", "http://churn-agent:3000", ]); let stdout = churning.stdout().await?; println!("{stdout}"); let stderr = churning.stderr().await?; println!("{stderr}"); churning.exit_code().await?; Ok(()) } async fn build_container( client: Arc, bin_name: &str, ) -> eyre::Result { let crates = &["crates/*", "ci"]; let debian_deps = &["libssl-dev", "pkg-config", "openssl", "git", "jq"]; let debian_image = "debian:bullseye".to_string(); let images = dagger_rust::build::RustBuild::new(client.clone()) .build_release( None::, RustVersion::Nightly, crates, debian_deps, vec![SlimImage::Debian { image: debian_image, deps: debian_deps .iter() .map(|s| s.to_string()) .collect::>(), architecture: dagger_rust::build::BuildArchitecture::Arm64, }], &bin_name, ) .await?; Ok(images.first().take().unwrap().clone()) }