From f49fb9df6f2e09f2980087a9337041e1cfc49d24 Mon Sep 17 00:00:00 2001 From: jakubmanczak Date: Sat, 4 Apr 2026 21:42:08 +0200 Subject: [PATCH] example compose.yaml, includestr styles, ignore default bind mount --- .dockerignore | 1 + .gitignore | 1 + compose.yaml | 20 ++++++++++++++++++++ src/web/mod.rs | 10 ++++++++-- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore index 4200a43..007d945 100644 --- a/.dockerignore +++ b/.dockerignore @@ -28,3 +28,4 @@ README.md readme **/*.db* **/*.db3* +/mnemodata diff --git a/.gitignore b/.gitignore index 6a38e1e..b6ee0c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /target .DS_Store /database +/mnemodata *.db *.db-shm *.db-wal diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..9fb6eac --- /dev/null +++ b/compose.yaml @@ -0,0 +1,20 @@ +services: + mnemosyne: + container_name: mnemosyne + build: + context: . + target: final + ports: + - 39321:39321 + restart: unless-stopped + volumes: + # Mnemosyne would greatly enjoy not having an ephemeral database. + # If you're okay with storing it side by side with the compose file, + # this is one way to do it. Another is to use a docker volume. + - ./mnemodata:/app/data + environment: + # DATABASE_URL is crucial for Mnemosyne to work; it will fail without it. + # point it at where you'd like your database to be. + - DATABASE_URL=/app/data/db.db + # Mnemosyne uses port 39321 for HTTP by default; + # - PORT=39321 diff --git a/src/web/mod.rs b/src/web/mod.rs index 1a68d4d..123320e 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -1,16 +1,22 @@ use axum::{ Router, + http::header, response::{IntoResponse, Redirect, Response}, + routing::get, }; -use tower_http::services::ServeFile; mod components; mod icons; mod pages; +pub const STYLES_CSS: &str = include_str!("./styles.css"); + pub fn web_router() -> Router { Router::new() - .route_service("/styles.css", ServeFile::new("src/web/styles.css")) + .route( + "/styles.css", + get(|| async { ([(header::CONTENT_TYPE, "text/css")], STYLES_CSS) }), + ) .merge(pages::pages()) }