-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* embed ui into the binary * make sure all required files are embedded * make the packaging actually work * add newlines * prepare workflow file for testing * add packaging step for .deb * defguard-core -> defguard * place the binary in /usr/bin * try without path interpolation * try without cross compilation * try with env passthrough * env -> conf * add frontend building step * set node version * add cache dependency path * remove node version from matrix * fix path * frozen lockfile * build rpm * cleanup and fix docker * fix .env file * remove possibly unnecessary step * cleanup * cleanup 2 * sort cargo toml * add new lines * change dockerfile * sort whole file * remove unused file
- Loading branch information
1 parent
9ae4a62
commit 6eddd52
Showing
12 changed files
with
207 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-s dir | ||
--name defguard | ||
--architecture x86_64 | ||
--description "defguard core service" | ||
--url "https://defguard.net/" | ||
--maintainer "teonite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[Unit] | ||
Description=defguard core service | ||
Documentation=https://defguard.gitbook.io/defguard/ | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
DynamicUser=yes | ||
User=defguard | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
EnvironmentFile=/etc/defguard/core.conf | ||
ExecStart=/usr/bin/defguard | ||
KillMode=process | ||
KillSignal=SIGINT | ||
LimitNOFILE=65536 | ||
LimitNPROC=infinity | ||
Restart=on-failure | ||
RestartSec=2 | ||
TasksMax=infinity | ||
OOMScoreAdjust=-1000 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use axum::{ | ||
http::{header, StatusCode, Uri}, | ||
response::{IntoResponse, Response}, | ||
}; | ||
use rust_embed::Embed; | ||
|
||
pub async fn web_asset(uri: Uri) -> impl IntoResponse { | ||
let mut path = uri.path().trim_start_matches('/').to_string(); | ||
// Rewrite the path to match the structure of the embedded files | ||
path.insert_str(0, "dist/"); | ||
StaticFile(path) | ||
} | ||
|
||
pub async fn index() -> impl IntoResponse { | ||
web_asset(Uri::from_static("/index.html")).await | ||
} | ||
|
||
pub async fn svg(uri: Uri) -> impl IntoResponse { | ||
let mut path = uri.path().trim_start_matches('/').to_string(); | ||
// Rewrite the path to match the structure of the embedded files | ||
path.insert_str(0, "src/shared/images/"); | ||
StaticFile(path) | ||
} | ||
|
||
#[derive(Embed)] | ||
#[folder = "web/"] | ||
#[include = "dist/*"] | ||
#[include = "src/shared/images/*"] | ||
struct WebAsset; | ||
|
||
pub struct StaticFile<T>(pub T); | ||
|
||
impl<T> IntoResponse for StaticFile<T> | ||
where | ||
T: Into<String>, | ||
{ | ||
fn into_response(self) -> Response { | ||
let path = self.0.into(); | ||
|
||
match WebAsset::get(path.as_str()) { | ||
Some(content) => { | ||
let mime = mime_guess::from_path(path).first_or_octet_stream(); | ||
([(header::CONTENT_TYPE, mime.as_ref())], content.data).into_response() | ||
} | ||
None => (StatusCode::NOT_FOUND, "404 Not Found").into_response(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.