fix(cli): serving web ui in Docker/AppImage
parent
faa75278a1
commit
852d64b38d
|
@ -819,12 +819,6 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
|
||||
|
||||
[[package]]
|
||||
name = "constcat"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d5cd0c57ef83705837b1cb872c973eff82b070846d3e23668322b2c0f8246d0"
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.4.0"
|
||||
|
@ -3335,7 +3329,6 @@ dependencies = [
|
|||
"bytes",
|
||||
"chrono",
|
||||
"clap",
|
||||
"constcat",
|
||||
"diesel",
|
||||
"diesel_migrations",
|
||||
"filebuffer",
|
||||
|
|
|
@ -90,7 +90,6 @@ url = "2"
|
|||
bytes = "1.4.0"
|
||||
signal-hook = "0.3.15"
|
||||
actix-web-lab = { version = "0.20.2", features = ["spa"] }
|
||||
constcat = "0.4.1"
|
||||
|
||||
[build-dependencies]
|
||||
shadow-rs = { version = "0.23", default-features = false }
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
use constcat::concat;
|
||||
use std::env::current_exe;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use shadow_rs::shadow;
|
||||
use shadow_rs::{is_debug, shadow};
|
||||
|
||||
shadow!(build);
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const RESOURCE_PATH: &str = "../share/upend";
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub const RESOURCE_PATH: &str = "./tmp/resources";
|
||||
|
||||
pub const WEBUI_PATH: &str = concat!(RESOURCE_PATH, "/webui");
|
||||
|
||||
lazy_static! {
|
||||
pub static ref RESOURCE_PATH: PathBuf = if is_debug() {
|
||||
let project_root = build::CARGO_MANIFEST_DIR.parse::<PathBuf>().unwrap();
|
||||
project_root.join("./tmp/resources")
|
||||
} else {
|
||||
current_exe()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("../share/upend")
|
||||
};
|
||||
pub static ref WEBUI_PATH: PathBuf = RESOURCE_PATH.join("webui");
|
||||
static ref APP_USER_AGENT: String = format!("upend / {}", build::PKG_VERSION);
|
||||
pub static ref REQWEST_CLIENT: reqwest::blocking::Client = reqwest::blocking::Client::builder()
|
||||
.user_agent(APP_USER_AGENT.as_str())
|
||||
|
|
|
@ -345,11 +345,11 @@ async fn main() -> Result<()> {
|
|||
let webui_enabled = if args.no_ui {
|
||||
false
|
||||
} else {
|
||||
let exists = Path::new(WEBUI_PATH).exists();
|
||||
let exists = WEBUI_PATH.exists();
|
||||
if !exists {
|
||||
warn!(
|
||||
"Couldn't locate Web UI directory ({:?}), disabling...",
|
||||
WEBUI_PATH
|
||||
WEBUI_PATH.to_owned()
|
||||
);
|
||||
}
|
||||
exists
|
||||
|
|
|
@ -71,8 +71,8 @@ where
|
|||
if ui_enabled {
|
||||
return app.service(
|
||||
spa()
|
||||
.index_file(crate::common::WEBUI_PATH.to_owned() + "/index.html")
|
||||
.static_resources_location(crate::common::WEBUI_PATH)
|
||||
.index_file(crate::common::WEBUI_PATH.to_str().unwrap().to_owned() + "/index.html")
|
||||
.static_resources_location(crate::common::WEBUI_PATH.to_str().unwrap())
|
||||
.finish(),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue