64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
|
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);
|
||
|
|
||
|
cli.with_service_binding("churn-agent", agent.id().await?)
|
||
|
.with_service_binding("churn-server", server.id().await?)
|
||
|
.with_exec(vec![
|
||
|
"churn",
|
||
|
"health",
|
||
|
"--server",
|
||
|
"churn-server:3000",
|
||
|
"--agent",
|
||
|
"churn-agent:3000",
|
||
|
])
|
||
|
.exit_code()
|
||
|
.await?;
|
||
|
|
||
|
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())
|
||
|
}
|