diff --git a/Dockerfile b/Dockerfile index eb8e5dd..f4a19b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,11 +11,13 @@ COPY --from=planner /app/recipe.json recipe.json RUN cargo chef cook --release --recipe-path recipe.json # Build application COPY . . -RUN cargo build --release --manifest-path api/Cargo.toml +RUN cargo build --release FROM debian:bookworm-slim AS runtime +RUN apt update +RUN apt install ca-certificates -y WORKDIR /app -COPY --from=builder /app/static /usr/local/bin -COPY --from=builder /app/target/release/api /usr/local/bin +COPY public/ /usr/local/bin +COPY --from=builder /app/target/release/power-scouter /usr/local/bin EXPOSE 8080 -ENTRYPOINT ["/usr/local/bin/api"] +ENTRYPOINT ["/usr/local/bin/power-scouter"] diff --git a/src/main.rs b/src/main.rs index 4785098..8ee64b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ mod routes; use axum::{ extract::Json, - response::{self, Html}, + response::Html, routing::{get, post}, Router, }; @@ -18,22 +18,6 @@ use helpers::calculations::calculate_score; use models::{CompetitorInfo, Score}; use routes::home::home_route; -async fn hello_world() -> &'static str { - "Hello World!" -} - -async fn calculate_results(Json(competitor_info): Json) -> Json { - let results = calculate_score(competitor_info); - Json(results) -} - -async fn home_endpoint() -> response::Result> { - let mut app = VirtualDom::new(home_route); - let _ = app.rebuild(); - - Ok(Html(dioxus_ssr::render(&app))) -} - #[tokio::main] async fn main() { let router = Router::new() @@ -48,3 +32,24 @@ async fn main() { axum::serve(listener, router).await.unwrap(); } + +async fn hello_world() -> &'static str { + "Hello World!" +} + +async fn calculate_results(Json(competitor_info): Json) -> Json { + let results = calculate_score(competitor_info); + Json(results) +} + +async fn home_endpoint() -> Html { + tokio::task::spawn_blocking(move || async move { + let mut app = VirtualDom::new(home_route); + let _ = app.rebuild(); + + Html(dioxus_ssr::render(&app)) + }) + .await + .unwrap() + .await +}