This commit is contained in:
alice 2026-04-23 15:47:06 -04:00
parent d20a4a2b8c
commit 96639b982b
14 changed files with 36 additions and 10 deletions

View file

@ -1,11 +1,11 @@
FROM rust:1.75-slim as builder FROM rust:1.95-slim-bookworm as builder
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY . . COPY . .
RUN cargo build --release RUN cargo build --release
FROM debian:bookworm-slim FROM debian:bookworm-slim
WORKDIR /app 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 COPY ./static /app/static
EXPOSE 3030 EXPOSE 3030

5
build.sh Executable file
View file

@ -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

View file

@ -2,10 +2,21 @@ use warp::Filter;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let hello = warp::path!("hello" / String) let static_files = warp::fs::dir("static");
.map(|name| format!("Hello, {}!", name));
warp::serve(hello) let root = warp::path::end()
.and(warp::header::optional::<String>("accept-language"))
.map(|lang: Option<String>| {
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)) .run(([0,0,0,0], 3030))
.await; .await;
} }

5
static/en/index.html Normal file
View file

@ -0,0 +1,5 @@
<title>Spencer Whitehead</title>
<link rel="stylesheet" href="/assets/main.css">
<body>
<p>This is the personal website of Spencer Whitehead.</p>
</body>

5
static/fr/index.html Normal file
View file

@ -0,0 +1,5 @@
<title>Spencer Whitehead</title>
<link rel="stylesheet" href="/assets/main.css">
<body>
<p>Ceci est le site web personel de Spencer Whitehead.</p>
</body>

View file

@ -1,5 +1,6 @@
<title>my website</title> <title>Spencer Whitehead</title>
<link rel="stylesheet" href="/static/main.css"> <link rel="stylesheet" href="/assets/main.css">
<body> <body>
<p>This is the personal website of Spencer Whitehead.</p> <p><a href="/en/"> English </a></p>
<p><a href="/fr/"> Français </a><p>
</body> </body>

View file

@ -1,4 +1,3 @@
User-agent: * User-agent: *
Disallow: / Disallow: /
Allow: /academic/ Allow: /en/academic/
Disallow: /academic/teaching/socrates