init
This commit is contained in:
commit
dae8fed78f
6 changed files with 3690 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
/tar
|
3614
Cargo.lock
generated
Normal file
3614
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "navos-site"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
based = { git = "https://git.hydrar.de/jmarya/based" }
|
||||
env_logger = "0.11.8"
|
||||
rocket = "0.5.1"
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
FROM rust:buster as builder
|
||||
|
||||
RUN rustup default nightly
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
||||
RUN cargo build --release
|
||||
|
||||
FROM git.hydrar.de/navos/navos:latest
|
||||
|
||||
RUN pacman -Syu --noconfirm && pacman -Syu --noconfirm openssl-1.1 tar xz zstd
|
||||
|
||||
COPY --from=builder /app/target/release/navos-site /navos-site
|
||||
|
||||
WORKDIR /
|
||||
|
||||
CMD ["/navos-site"]
|
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
services:
|
||||
navos_site:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:8000"
|
||||
volumes:
|
||||
- ./tar:/tar
|
||||
environment:
|
||||
- "RUST_LOG=info"
|
||||
- "ROCKET_ADDRESS=0.0.0.0"
|
37
src/main.rs
Normal file
37
src/main.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
use based::request::assets::DataResponse;
|
||||
use rocket::{get, launch, routes};
|
||||
|
||||
#[get("/")]
|
||||
pub async fn index() -> String {
|
||||
String::new()
|
||||
}
|
||||
|
||||
#[get("/rootfs/<arch>/rootfs.tar.xz")]
|
||||
pub async fn rootfs_tar(arch: &str) -> DataResponse {
|
||||
match arch {
|
||||
"aarch64" => {
|
||||
DataResponse::new_file("./tar/aarch64.tar.xz", "application/tar".to_string(), Some(60 * 60))
|
||||
},
|
||||
"x86_64" => {
|
||||
DataResponse::new_file("./tar/x86_64.tar.xz", "application/tar".to_string(), Some(60 * 60))
|
||||
},
|
||||
_ => {
|
||||
DataResponse::new("Weird arch".as_bytes().to_vec(), "text/plain".to_string(), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[launch]
|
||||
async fn rocket() -> _ {
|
||||
env_logger::init();
|
||||
|
||||
rocket::build()
|
||||
.mount(
|
||||
"/",
|
||||
routes![
|
||||
index,
|
||||
rootfs_tar
|
||||
],
|
||||
)
|
||||
}
|
Loading…
Add table
Reference in a new issue