2023-08-24 17:22:45 +02:00
|
|
|
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);
|
|
|
|
|
2023-08-25 21:52:28 +02:00
|
|
|
let churning = cli
|
|
|
|
.with_service_binding("churn-agent", agent.id().await?)
|
2023-08-24 17:22:45 +02:00
|
|
|
.with_service_binding("churn-server", server.id().await?)
|
|
|
|
.with_exec(vec![
|
|
|
|
"churn",
|
|
|
|
"health",
|
|
|
|
"--server",
|
2023-08-25 21:52:28 +02:00
|
|
|
"http://churn-server:3000",
|
2023-08-24 17:22:45 +02:00
|
|
|
"--agent",
|
2023-08-25 21:52:28 +02:00
|
|
|
"http://churn-agent:3000",
|
|
|
|
]);
|
|
|
|
|
|
|
|
let stdout = churning.stdout().await?;
|
|
|
|
println!("{stdout}");
|
|
|
|
let stderr = churning.stderr().await?;
|
|
|
|
println!("{stderr}");
|
|
|
|
|
|
|
|
churning.exit_code().await?;
|
2023-08-24 17:22:45 +02:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn build_container(
|
|
|
|
client: Arc<Query>,
|
|
|
|
bin_name: &str,
|
|
|
|
) -> eyre::Result<dagger_sdk::Container> {
|
|
|
|
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::<PathBuf>,
|
|
|
|
RustVersion::Nightly,
|
|
|
|
crates,
|
|
|
|
debian_deps,
|
|
|
|
vec![SlimImage::Debian {
|
|
|
|
image: debian_image,
|
|
|
|
deps: debian_deps
|
|
|
|
.iter()
|
|
|
|
.map(|s| s.to_string())
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
architecture: dagger_rust::build::BuildArchitecture::Arm64,
|
|
|
|
}],
|
|
|
|
&bin_name,
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(images.first().take().unwrap().clone())
|
|
|
|
}
|