mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
enable build htmx in docker (#2893)
This commit is contained in:
parent
966e26f874
commit
bf73332088
7
Makefile
7
Makefile
|
@ -7,6 +7,7 @@ CONTAINER_BUILD_ARGS ?=
|
|||
MARKDOWN_FORMAT_ARGS ?= --options-line-width=100
|
||||
CONTAINER_TOOL ?= docker
|
||||
BUILDKIT_PROGRESS ?= plain
|
||||
KANIDM_FEATURES ?= ""
|
||||
TESTS ?=
|
||||
BOOK_VERSION ?= master
|
||||
GIT_COMMIT := $(shell git rev-parse HEAD)
|
||||
|
@ -48,7 +49,7 @@ buildx/kanidmd:
|
|||
-t $(IMAGE_BASE)/server:$(IMAGE_EXT_VERSION) \
|
||||
--progress $(BUILDKIT_PROGRESS) \
|
||||
--build-arg "KANIDM_BUILD_PROFILE=container_generic" \
|
||||
--build-arg "KANIDM_FEATURES=" \
|
||||
--build-arg "KANIDM_FEATURES=$(KANIDM_FEATURES)" \
|
||||
--compress \
|
||||
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
|
||||
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
|
||||
|
@ -64,7 +65,7 @@ buildx/kanidm_tools:
|
|||
-t $(IMAGE_BASE)/tools:$(IMAGE_EXT_VERSION) \
|
||||
--progress $(BUILDKIT_PROGRESS) \
|
||||
--build-arg "KANIDM_BUILD_PROFILE=container_generic" \
|
||||
--build-arg "KANIDM_FEATURES=" \
|
||||
--build-arg "KANIDM_FEATURES=$(KANIDM_FEATURES)" \
|
||||
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
|
||||
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
|
||||
$(CONTAINER_BUILD_ARGS) .
|
||||
|
@ -101,7 +102,7 @@ build/orca:
|
|||
@$(CONTAINER_TOOL) build $(CONTAINER_TOOL_ARGS) -f tools/orca/Dockerfile \
|
||||
-t $(IMAGE_BASE)/orca:$(IMAGE_VERSION) \
|
||||
--build-arg "KANIDM_BUILD_PROFILE=container_generic" \
|
||||
--build-arg "KANIDM_FEATURES=" \
|
||||
--build-arg "KANIDM_FEATURES=$(KANIDM_FEATURES)" \
|
||||
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
|
||||
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
|
||||
$(CONTAINER_BUILD_ARGS) .
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
web_ui_pkg_path = "/pkg"
|
||||
htmx_ui_pkg_path = "/hpkg"
|
||||
# Don't set the cpu_flags to autodetect for this platform
|
||||
# cpu_flags = "none"
|
||||
admin_bind_path = "/data/kanidmd.sock"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
web_ui_pkg_path = "../web_ui/pkg"
|
||||
htmx_ui_pkg_path = "../core/static"
|
||||
# Set to native for developer machines.
|
||||
cpu_flags = "native"
|
||||
admin_bind_path = "/tmp/kanidmd.sock"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
web_ui_pkg_path = "/usr/share/kanidm/ui/pkg"
|
||||
web_ui_pkg_path = "/usr/share/kanidm/ui/hpkg"
|
||||
# Don't set the value for autodetect
|
||||
# cpu_flags = "none"
|
||||
admin_bind_path = "/var/run/kanidmd/sock"
|
||||
|
|
|
@ -53,6 +53,7 @@ impl std::fmt::Display for CpuOptLevel {
|
|||
#[serde(deny_unknown_fields)]
|
||||
struct ProfileConfig {
|
||||
web_ui_pkg_path: String,
|
||||
htmx_ui_pkg_path: String,
|
||||
#[serde(default)]
|
||||
cpu_flags: CpuOptLevel,
|
||||
admin_bind_path: String,
|
||||
|
@ -122,6 +123,10 @@ pub fn apply_profile() {
|
|||
"cargo:rustc-env=KANIDM_WEB_UI_PKG_PATH={}",
|
||||
profile_cfg.web_ui_pkg_path
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=KANIDM_HTMX_UI_PKG_PATH={}",
|
||||
profile_cfg.htmx_ui_pkg_path
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=KANIDM_ADMIN_BIND_PATH={}",
|
||||
profile_cfg.admin_bind_path
|
||||
|
|
|
@ -73,6 +73,7 @@ RUN \
|
|||
|
||||
COPY --from=builder /usr/src/kanidm/target/release/kanidmd /sbin/
|
||||
COPY --from=builder /usr/src/kanidm/server/web_ui/pkg /pkg
|
||||
COPY --from=builder /usr/src/kanidm/server/core/static /hpkg
|
||||
RUN chmod +x /sbin/kanidmd
|
||||
|
||||
EXPOSE 8443 3636
|
||||
|
|
|
@ -129,7 +129,7 @@ pub fn get_js_files(role: ServerRole) -> Result<JavaScriptFiles, ()> {
|
|||
if !matches!(role, ServerRole::WriteReplicaNoUI) {
|
||||
// let's set up the list of js module hashes
|
||||
let pkg_path = if cfg!(feature = "ui_htmx") {
|
||||
"../core/static".to_string()
|
||||
env!("KANIDM_HTMX_UI_PKG_PATH").to_owned()
|
||||
} else {
|
||||
env!("KANIDM_WEB_UI_PKG_PATH").to_owned()
|
||||
};
|
||||
|
@ -300,6 +300,19 @@ pub async fn create_https_server(
|
|||
let app = match config.role {
|
||||
ServerRole::WriteReplicaNoUI => app,
|
||||
ServerRole::WriteReplica | ServerRole::ReadOnlyReplica => {
|
||||
let pkg_router = if cfg!(feature = "ui_htmx") {
|
||||
let pkg_path = PathBuf::from(env!("KANIDM_HTMX_UI_PKG_PATH"));
|
||||
if !pkg_path.exists() {
|
||||
eprintln!(
|
||||
"Couldn't find htmx UI package path: ({}), quitting.",
|
||||
env!("KANIDM_HTMX_UI_PKG_PATH")
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
Router::new().nest_service("/pkg", ServeDir::new(pkg_path))
|
||||
// TODO: Add in the br precompress
|
||||
} else {
|
||||
|
||||
let pkg_path = PathBuf::from(env!("KANIDM_WEB_UI_PKG_PATH"));
|
||||
if !pkg_path.exists() {
|
||||
eprintln!(
|
||||
|
@ -308,11 +321,7 @@ pub async fn create_https_server(
|
|||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
let pkg_router = if cfg!(feature = "ui_htmx") {
|
||||
// TODO! This should be from webui pkg path in future!!!
|
||||
Router::new().nest_service("/pkg", ServeDir::new("../core/static"))
|
||||
// TODO: Add in the br precompress
|
||||
} else {
|
||||
|
||||
Router::new()
|
||||
.nest_service("/pkg", ServeDir::new(pkg_path).precompressed_br())
|
||||
.layer(middleware::compression::new())
|
||||
|
|
Loading…
Reference in a new issue