update
This commit is contained in:
parent
d20a4a2b8c
commit
96639b982b
14 changed files with 36 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
5
build.sh
Executable file
5
build.sh
Executable 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
|
||||
17
src/main.rs
17
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::<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))
|
||||
.await;
|
||||
}
|
||||
|
|
|
|||
5
static/en/index.html
Normal file
5
static/en/index.html
Normal 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
5
static/fr/index.html
Normal 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>
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<title>my website</title>
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
<title>Spencer Whitehead</title>
|
||||
<link rel="stylesheet" href="/assets/main.css">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
User-agent: *
|
||||
Disallow: /
|
||||
Allow: /academic/
|
||||
Disallow: /academic/teaching/socrates
|
||||
Allow: /en/academic/
|
||||
|
|
|
|||
Loading…
Reference in a new issue