2023-11-25 23:14:38 +01:00
|
|
|
use dagger_rust::build::{RustVersion, SlimImage};
|
2023-10-22 12:09:57 +02:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
pub async fn main() -> eyre::Result<()> {
|
2024-08-01 22:19:59 +02:00
|
|
|
dagger_sdk::connect(|client| async move {
|
|
|
|
let rust_build = dagger_rust::leptos::LeptosBuild::new(client.clone());
|
|
|
|
|
|
|
|
let containers = rust_build
|
|
|
|
.build_release(
|
|
|
|
Some("testdata"),
|
|
|
|
RustVersion::Nightly,
|
|
|
|
&["crates/*"],
|
|
|
|
&[
|
|
|
|
"openssl",
|
|
|
|
"libssl-dev",
|
|
|
|
"pkg-config",
|
|
|
|
"musl-tools",
|
|
|
|
"ca-certificates",
|
2023-10-22 12:09:57 +02:00
|
|
|
],
|
2024-08-01 22:19:59 +02:00
|
|
|
vec![SlimImage::Debian {
|
|
|
|
image: "debian:bullseye".into(),
|
|
|
|
deps: vec![
|
|
|
|
"openssl".into(),
|
|
|
|
"libssl-dev".into(),
|
|
|
|
"pkg-config".into(),
|
|
|
|
"musl-tools".into(),
|
|
|
|
"ca-certificates".into(),
|
|
|
|
],
|
|
|
|
architecture: dagger_rust::build::BuildArchitecture::Amd64,
|
|
|
|
}],
|
|
|
|
"hackernews_axum",
|
|
|
|
)
|
|
|
|
.await?;
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
let container = containers.first().unwrap();
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
container.directory("/mnt/app").export("output").await?;
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
let tunnel = client.host().tunnel(
|
|
|
|
container
|
|
|
|
.with_env_variable("LEPTOS_SITE_ADDR", "0.0.0.0:8080")
|
|
|
|
.with_exec(vec!["/mnt/app/hackernews_axum"])
|
|
|
|
.as_service(),
|
|
|
|
);
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
tunnel.start().await?;
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
let endpoint = tunnel
|
|
|
|
.endpoint_opts(
|
|
|
|
dagger_sdk::ServiceEndpointOptsBuilder::default()
|
|
|
|
.scheme("http")
|
|
|
|
.build()?,
|
|
|
|
)
|
|
|
|
.await?;
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
println!("running on: {endpoint}, press enter to stop");
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
2023-10-22 12:09:57 +02:00
|
|
|
|
2024-08-01 22:19:59 +02:00
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.await?;
|
2023-10-22 12:09:57 +02:00
|
|
|
Ok(())
|
|
|
|
}
|