feat: add simple health check
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
12
crates/churning/Cargo.toml
Normal file
12
crates/churning/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "churning"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dagger-sdk = "0.2.2"
|
||||
dagger-rust = "0.2.0"
|
||||
tokio.workspace = true
|
||||
eyre = "*"
|
63
crates/churning/src/main.rs
Normal file
63
crates/churning/src/main.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
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())
|
||||
}
|
Reference in New Issue
Block a user