diff --git a/.gitignore b/.gitignore index 0b188bc..e2aab4f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,8 @@ target/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + + +# Added by cargo + +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0944cf8 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "druid" +version = "0.1.0" +edition = "2024" + +[dependencies] +rocket = "0.5.1" + +[dependencies.rocket_dyn_templates] +version = "0.2.0" +features = ["tera"] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0a5c441 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# -------------------- +# STAGE 1: The Builder +FROM rust:1.96 as builder + +WORKDIR /app +COPY Cargo.* ./ + +# Create a dummy main.rs so the dependencies can be compiled and cached +RUN mkdir src && \ + echo "fn main() { println!(\"dummy\"); }" > src/main.rs +RUN cargo build --release + +# Copy in the real source code changes +COPY src ./src +# Run the real build command +RUN cargo build --release + +# -------------------- +# STAGE 2: The Final, Minimal Image +FROM debian:stable-slim + +WORKDIR /usr/src/druid + +# Copy ONLY the compiled binary from the builder stage +COPY --from=builder /app/target/release/druid /usr/local/bin + +ENV ROCKET_ADDRESS=0.0.0.0 + +# Define the command that runs your application +CMD ["/usr/local/bin/druid"] \ No newline at end of file diff --git a/README.md b/README.md index e3bddbd..a8d14f8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # Druid -Web app for storing PC hardware benchmarking data \ No newline at end of file +Web app for storing PC hardware benchmarking data + +## License + +This project is licensed under the BSD 3-Clause license. diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c9e0b84 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,22 @@ +#[macro_use] extern crate rocket; +use rocket_dyn_templates::{Template, context}; + +#[get("/")] +fn index() -> Template { + Template::render("index", context! { + title: "Dashboard", + }) +} + +#[get("/about")] +fn about() -> Template { + Template::render("about", context! { + title: "About Druid", + }) +} + +#[launch] +fn rocket() -> _ { + rocket::build().attach(Template::fairing()) + .mount("/", routes![index, about]) +} diff --git a/templates/about.html.tera b/templates/about.html.tera new file mode 100644 index 0000000..bb998d7 --- /dev/null +++ b/templates/about.html.tera @@ -0,0 +1,11 @@ + + +
+ + +This is about Druid.
+ + \ No newline at end of file diff --git a/templates/index.html.tera b/templates/index.html.tera new file mode 100644 index 0000000..cb81308 --- /dev/null +++ b/templates/index.html.tera @@ -0,0 +1,11 @@ + + + + + +This is a test.
+ + \ No newline at end of file