diff --git a/Dockerfile b/Dockerfile index 3d710f0..f1579fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM rust:1.75-slim as builder +FROM rust:1.95-slim-bookworm as builder WORKDIR /usr/src/app COPY . . RUN cargo build --release FROM debian:bookworm-slim WORKDIR /app -COPY --from=builder /usr/src/app/target/release/your_warp_bin /app/warp_server +COPY --from=builder /usr/src/app/target/release/website /app/warp_server COPY ./static /app/static EXPOSE 3030 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..a29651a --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +sudo buildah bud -t warp-server:local . +sudo buildah push warp-server:local docker-archive:warp.tar +sudo k3s ctr -n k8s.io images import warp.tar +sudo rm warp.tar +sudo k3s kubectl rollout restart deployment website diff --git a/src/main.rs b/src/main.rs index 9a1b927..3fb43f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,10 +2,21 @@ use warp::Filter; #[tokio::main] async fn main() { - let hello = warp::path!("hello" / String) - .map(|name| format!("Hello, {}!", name)); + let static_files = warp::fs::dir("static"); - warp::serve(hello) + let root = warp::path::end() + .and(warp::header::optional::("accept-language")) + .map(|lang: Option| { + let target = match lang { + Some(l) if l.starts_with("fr") => "/fr/", + _ => "/en/", + }; + warp::redirect(warp::http::Uri::from_static(target)) + }); + + let routes = root.or(static_files); + + warp::serve(routes) .run(([0,0,0,0], 3030)) .await; } diff --git a/static/main.css b/static/assets/main.css similarity index 100% rename from static/main.css rename to static/assets/main.css diff --git a/static/academic/cv/index.html b/static/en/academic/cv/index.html similarity index 100% rename from static/academic/cv/index.html rename to static/en/academic/cv/index.html diff --git a/static/academic/cv/resume.pdf b/static/en/academic/cv/resume.pdf similarity index 100% rename from static/academic/cv/resume.pdf rename to static/en/academic/cv/resume.pdf diff --git a/static/academic/index.html b/static/en/academic/index.html similarity index 100% rename from static/academic/index.html rename to static/en/academic/index.html diff --git a/static/academic/teaching/2023/106/grading_info/index.html b/static/en/academic/teaching/2023/106/grading_info/index.html similarity index 100% rename from static/academic/teaching/2023/106/grading_info/index.html rename to static/en/academic/teaching/2023/106/grading_info/index.html diff --git a/static/academic/teaching/2023/106/index.html b/static/en/academic/teaching/2023/106/index.html similarity index 100% rename from static/academic/teaching/2023/106/index.html rename to static/en/academic/teaching/2023/106/index.html diff --git a/static/academic/teaching/index.html b/static/en/academic/teaching/index.html similarity index 100% rename from static/academic/teaching/index.html rename to static/en/academic/teaching/index.html diff --git a/static/en/index.html b/static/en/index.html new file mode 100644 index 0000000..876e394 --- /dev/null +++ b/static/en/index.html @@ -0,0 +1,5 @@ +Spencer Whitehead + + +

This is the personal website of Spencer Whitehead.

+ diff --git a/static/fr/index.html b/static/fr/index.html new file mode 100644 index 0000000..edd8a5a --- /dev/null +++ b/static/fr/index.html @@ -0,0 +1,5 @@ +Spencer Whitehead + + +

Ceci est le site web personel de Spencer Whitehead.

+ diff --git a/static/index.html b/static/index.html index 5b88347..9fb290d 100644 --- a/static/index.html +++ b/static/index.html @@ -1,5 +1,6 @@ -my website - +Spencer Whitehead + -

This is the personal website of Spencer Whitehead.

+

English

+

Français

diff --git a/static/robots.txt b/static/robots.txt index 4cb8dce..f854c23 100644 --- a/static/robots.txt +++ b/static/robots.txt @@ -1,4 +1,3 @@ User-agent: * Disallow: / -Allow: /academic/ -Disallow: /academic/teaching/socrates +Allow: /en/academic/