feat: create docker dependencies for cloud deployment
This commit is contained in:
1 parent
a01feb5e34
commit
15b8aee844
4 files changed
+58
-28
No files matched your search
+6
-3
@@ -1,7 +1,7 @@
|
|||||||
FROM rust:1.86 AS builder
|
FROM rust:1.90 AS builder
|
||||||
|
|
||||||
# Install node for tailwind capability
|
# Install node for tailwind capability
|
||||||
RUN apt-get update -y && apt-get install -y --no-install-recommends clang libc6
|
RUN apt-get update -y && apt-get install -y --no-install-recommends clang libc6 mold
|
||||||
RUN wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
|
RUN wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
|
||||||
RUN tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
|
RUN tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
|
||||||
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||||
@@ -15,6 +15,7 @@ WORKDIR /app
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Setup fnm and build with leptos
|
# Setup fnm and build with leptos
|
||||||
|
# If this doesn't work, we should use nvm as this is a proven solution.
|
||||||
RUN cargo binstall fnm -y \
|
RUN cargo binstall fnm -y \
|
||||||
&& fnm --version \
|
&& fnm --version \
|
||||||
&& eval "$(fnm env)" \
|
&& eval "$(fnm env)" \
|
||||||
@@ -26,7 +27,7 @@ RUN cargo binstall fnm -y \
|
|||||||
|
|
||||||
# Start second phase of build - install ca-certs and copy all build outputs from previous step into a
|
# Start second phase of build - install ca-certs and copy all build outputs from previous step into a
|
||||||
# Debian image in the /app directory.
|
# Debian image in the /app directory.
|
||||||
FROM debian:bookworm-slim AS runtime
|
FROM debian:trixie-slim AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apt-get update -y \
|
RUN apt-get update -y \
|
||||||
&& apt-get install -y --no-install-recommends openssl ca-certificates \
|
&& apt-get install -y --no-install-recommends openssl ca-certificates \
|
||||||
@@ -46,6 +47,8 @@ COPY --from=builder /app/Cargo.toml /app/
|
|||||||
ENV RUST_LOG="info"
|
ENV RUST_LOG="info"
|
||||||
ENV LEPTOS_SITE_ADDR="0.0.0.0:8080"
|
ENV LEPTOS_SITE_ADDR="0.0.0.0:8080"
|
||||||
ENV LEPTOS_SITE_ROOT="site"
|
ENV LEPTOS_SITE_ROOT="site"
|
||||||
|
# Staging URL for server.
|
||||||
|
ENV LP_SITE_ORIGIN="http://testing-url.com"
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
# Don't forget about project_name
|
# Don't forget about project_name
|
||||||
|
|||||||
+5
-8
@@ -1,9 +1,6 @@
|
|||||||
|
services:
|
||||||
services:
|
scholarships-rs:
|
||||||
leptos-watch:
|
build: .
|
||||||
image: rust:1.86
|
image: scholarships-rs-runner:latest
|
||||||
ports:
|
ports:
|
||||||
- '3000:3000'
|
- '8080:8080'
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
command: cargo leptos watch
|
|
||||||
+44
-17
@@ -1,9 +1,8 @@
|
|||||||
|
use leptos::logging::log;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_meta::{MetaTags, Stylesheet, Title, provide_meta_context};
|
use leptos_meta::{MetaTags, Stylesheet, Title, provide_meta_context};
|
||||||
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
|
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
|
||||||
use leptos_router::{components::{Route, Router, Routes}, path};
|
use leptos_router::{components::{Route, Router, Routes}, path};
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use crate::pages::{AboutPage, HomePage, LoanerPage, TestPage};
|
use crate::pages::{AboutPage, HomePage, LoanerPage, TestPage};
|
||||||
|
|
||||||
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
||||||
@@ -29,12 +28,53 @@ pub fn App() -> impl IntoView {
|
|||||||
// Provides context that manages stylesheets, titles, meta tags, etc.
|
// Provides context that manages stylesheets, titles, meta tags, etc.
|
||||||
provide_meta_context();
|
provide_meta_context();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
// injects a stylesheet into the document <head>
|
||||||
|
// id=leptos means cargo-leptos will hot-reload this stylesheet
|
||||||
|
<Stylesheet id="leptos" href="/pkg/scholarships-rs-wasm.css"/>
|
||||||
|
|
||||||
|
// sets the document title
|
||||||
|
<Title text="R15 Scholarship App DEV"/>
|
||||||
|
|
||||||
|
// content for this welcome page
|
||||||
|
<Router>
|
||||||
|
<AppWithRoutes />
|
||||||
|
</Router>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn use_origin() -> String {
|
||||||
|
#[cfg(target_arch = "wasm32")] {
|
||||||
|
use leptos::web_sys;
|
||||||
|
// Just get the current URL origin.
|
||||||
|
web_sys::window()
|
||||||
|
.unwrap()
|
||||||
|
.location()
|
||||||
|
.origin()
|
||||||
|
.unwrap_or("http://localhost:3000/".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))] {
|
||||||
|
// Read the expected origin out of an environment variable.
|
||||||
|
std::env::var("LP_SITE_ORIGIN").unwrap_or("http://localhost:3000/".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn AppWithRoutes() -> impl IntoView {
|
||||||
|
provide_meta_context();
|
||||||
|
|
||||||
|
let current_origin = use_origin();
|
||||||
|
log!("Current origin: {}", current_origin);
|
||||||
|
|
||||||
// Authentication setup
|
// Authentication setup
|
||||||
let parameters = AuthParameters {
|
let parameters = AuthParameters {
|
||||||
issuer: "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Lfjuy5zaM".into(),
|
issuer: "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Lfjuy5zaM".into(),
|
||||||
client_id: "10jr2h3vtpu9n7gj46pvg5qo2q".into(),
|
client_id: "10jr2h3vtpu9n7gj46pvg5qo2q".into(),
|
||||||
redirect_uri: Url::parse("http://localhost:3000").unwrap().to_string(),
|
redirect_uri: format!("{}/", use_origin()),
|
||||||
post_logout_redirect_uri: Url::parse("http://localhost:3000").unwrap().to_string(),
|
// redirect_uri: Url::parse(format!("{}", current_origin).as_str()).unwrap().to_string(),
|
||||||
|
// redirect_uri: Url::parse("http://localhost:3000").unwrap().to_string(),
|
||||||
|
post_logout_redirect_uri: current_origin,
|
||||||
scope: Some("openid%20profile%20email".into()),
|
scope: Some("openid%20profile%20email".into()),
|
||||||
audience: None,
|
audience: None,
|
||||||
challenge: Challenge::None,
|
challenge: Challenge::None,
|
||||||
@@ -47,18 +87,6 @@ pub fn App() -> impl IntoView {
|
|||||||
let _ = Auth::init(parameters);
|
let _ = Auth::init(parameters);
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
// injects a stylesheet into the document <head>
|
|
||||||
// id=leptos means cargo-leptos will hot-reload this stylesheet
|
|
||||||
<Stylesheet id="leptos" href="/pkg/scholarships-rs-wasm.css"/>
|
|
||||||
|
|
||||||
// <AuthLoading><p>"Authentication is loading"</p></AuthLoading>
|
|
||||||
// <AuthErrorContext><AuthErrorView/></AuthErrorContext>
|
|
||||||
|
|
||||||
// sets the document title
|
|
||||||
<Title text="R15 Scholarship App DEV"/>
|
|
||||||
|
|
||||||
// content for this welcome page
|
|
||||||
<Router>
|
|
||||||
<main>
|
<main>
|
||||||
// TODO Create a 404 page
|
// TODO Create a 404 page
|
||||||
<Routes fallback=|| "Page not found.".into_view()>
|
<Routes fallback=|| "Page not found.".into_view()>
|
||||||
@@ -69,7 +97,6 @@ pub fn App() -> impl IntoView {
|
|||||||
<Route path=path!("loaners/:form_name") view=LoanerPage />
|
<Route path=path!("loaners/:form_name") view=LoanerPage />
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
</Router>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use leptos::logging::log;
|
||||||
use crate::components::ActionButton;
|
use crate::components::ActionButton;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_oidc::AuthSignal;
|
use leptos_oidc::AuthSignal;
|
||||||
@@ -12,6 +13,8 @@ pub fn UnauthenticatedPage() -> impl IntoView {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Effect::new(move || log!("Generated login url: {:?}", login_url()));
|
||||||
|
|
||||||
let navigate = leptos_router::hooks::use_navigate();
|
let navigate = leptos_router::hooks::use_navigate();
|
||||||
|
|
||||||
view! (
|
view! (
|
||||||
|
|||||||
Reference in new issue
Block a user