standalone binary
embed the sqlite3 library aswell as all the templates.
This commit is contained in:
parent
9512807eb3
commit
a0aa251673
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1300,6 +1300,12 @@ dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gcc"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.3"
|
||||
@ -1676,6 +1682,7 @@ version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "370090ad578ba845a3ad4f383ceb3deba7abd51ab1915ad1f2c982cc6035e31c"
|
||||
dependencies = [
|
||||
"gcc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
@ -2183,6 +2190,7 @@ dependencies = [
|
||||
"diesel_migrations",
|
||||
"dotenv",
|
||||
"image",
|
||||
"libsqlite3-sys",
|
||||
"qrcode",
|
||||
"rand 0.8.3",
|
||||
"rpassword",
|
||||
|
@ -22,6 +22,7 @@ serde = "1.0"
|
||||
diesel = { version = "1.4", features = ["sqlite", "chrono"] }
|
||||
diesel_codegen = { version = "0.16.1", features = ["sqlite"] }
|
||||
diesel_migrations = "1.4"
|
||||
libsqlite3-sys = { version = "*", features = ["bundled"] }
|
||||
dotenv = "0.10.1"
|
||||
actix-identity = "0.3"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
@ -36,4 +37,9 @@ rpassword = "5.0"
|
||||
clap = "2.33"
|
||||
|
||||
[build-dependencies]
|
||||
actix-web-static-files = { git = "https://github.com/enaut/actix-web-static-files.git", branch = "enaut-must_use" }
|
||||
actix-web-static-files = { git = "https://github.com/enaut/actix-web-static-files.git", branch = "enaut-must_use" }
|
||||
|
||||
# optimize for size at cost of compilation speed.
|
||||
[profile.release]
|
||||
#lto = true
|
||||
#codegen-units = 1
|
@ -301,7 +301,8 @@ fn create_admin(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
fn apply_migrations(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
slog_info!(
|
||||
config.log,
|
||||
"Creating a database file and running the migrations:"
|
||||
"Creating a database file and running the migrations in the file {}:",
|
||||
&config.db.display()
|
||||
);
|
||||
let connection = queries::establish_connection(&config.db)?;
|
||||
crate::embedded_migrations::run_with_output(&connection, &mut std::io::stdout())?;
|
||||
|
44
src/main.rs
44
src/main.rs
@ -186,6 +186,48 @@ impl ServerConfig {
|
||||
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
|
||||
embed_migrations!("migrations/");
|
||||
|
||||
fn build_tera() -> Tera {
|
||||
let mut tera = Tera::default();
|
||||
|
||||
tera.add_raw_templates(vec![
|
||||
("admin.html", include_str!("../templates/admin.html")),
|
||||
("base.html", include_str!("../templates/base.html")),
|
||||
(
|
||||
"edit_link.html",
|
||||
include_str!("../templates/edit_link.html"),
|
||||
),
|
||||
(
|
||||
"edit_profile.html",
|
||||
include_str!("../templates/edit_profile.html"),
|
||||
),
|
||||
(
|
||||
"index_users.html",
|
||||
include_str!("../templates/index_users.html"),
|
||||
),
|
||||
("index.html", include_str!("../templates/index.html")),
|
||||
("login.html", include_str!("../templates/login.html")),
|
||||
(
|
||||
"not_found.html",
|
||||
include_str!("../templates/not_found.html"),
|
||||
),
|
||||
("signup.html", include_str!("../templates/signup.html")),
|
||||
(
|
||||
"submission.html",
|
||||
include_str!("../templates/submission.html"),
|
||||
),
|
||||
(
|
||||
"view_link.html",
|
||||
include_str!("../templates/view_link.html"),
|
||||
),
|
||||
(
|
||||
"view_profile.html",
|
||||
include_str!("../templates/view_profile.html"),
|
||||
),
|
||||
])
|
||||
.expect("failed to parse templates");
|
||||
tera
|
||||
}
|
||||
|
||||
#[allow(clippy::future_not_send)]
|
||||
async fn webservice(server_config: ServerConfig) -> std::io::Result<()> {
|
||||
let host_port = format!("{}:{}", &server_config.internal_ip, &server_config.port);
|
||||
@ -198,7 +240,7 @@ async fn webservice(server_config: ServerConfig) -> std::io::Result<()> {
|
||||
);
|
||||
|
||||
HttpServer::new(move || {
|
||||
let tera = Tera::new("templates/**/*").expect("failed to initialize the templates");
|
||||
let tera = build_tera(); //Tera::new("templates/**/*").expect("failed to initialize the templates");
|
||||
let generated = generate();
|
||||
App::new()
|
||||
.data(server_config.clone())
|
||||
|
Loading…
Reference in New Issue
Block a user