Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39a8443676 |
@@ -1,6 +1,6 @@
|
||||
# Stirling-PDF backend-only image — JAR built with -PbuildWithFrontend=false, UI ships separately.
|
||||
|
||||
ARG BASE_VERSION=1.0.2@sha256:c7698687f486707ddef9e0298587ca8b44c4e96185e1bdb0c3d119eb2bf9a82e
|
||||
ARG BASE_VERSION=1.0.2
|
||||
ARG BASE_IMAGE=stirlingtools/stirling-pdf-base:${BASE_VERSION}
|
||||
|
||||
# Stage 1: Build the Java application (backend only, no frontend)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Stirling-PDF - Full version (embedded frontend)
|
||||
# Uses pre-built base image for fast builds
|
||||
|
||||
ARG BASE_VERSION=1.0.2@sha256:c7698687f486707ddef9e0298587ca8b44c4e96185e1bdb0c3d119eb2bf9a82e
|
||||
ARG BASE_VERSION=1.0.2
|
||||
ARG BASE_IMAGE=stirlingtools/stirling-pdf-base:${BASE_VERSION}
|
||||
|
||||
# Stage 1: Build the Java application and frontend
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Extra fonts for air-gapped environments
|
||||
# Uses pre-built base image for fast builds
|
||||
|
||||
ARG BASE_VERSION=1.0.2@sha256:c7698687f486707ddef9e0298587ca8b44c4e96185e1bdb0c3d119eb2bf9a82e
|
||||
ARG BASE_VERSION=1.0.2
|
||||
ARG BASE_IMAGE=stirlingtools/stirling-pdf-base:${BASE_VERSION}
|
||||
|
||||
# Stage 1: Build the Java application and frontend
|
||||
@@ -54,7 +54,7 @@ RUN JPDFIUM_PLATFORM="$([ "$TARGETARCH" = arm64 ] && echo linux-arm64 || echo li
|
||||
--no-daemon
|
||||
|
||||
# Stage 2: Extract Spring Boot Layers
|
||||
FROM eclipse-temurin:25-jre-noble@sha256:b27ca47660a8fa837e47a8533b9b1a3a430295cf29ca28d91af4fd121572dc29 AS jar-extract
|
||||
FROM eclipse-temurin:25-jre-noble AS jar-extract
|
||||
WORKDIR /tmp
|
||||
COPY --from=app-build /app/app/core/build/libs/*.jar app.jar
|
||||
RUN java -Djarmode=tools -jar app.jar extract --layers --destination /layers
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# syntax=docker/dockerfile:1.5
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim@sha256:531f855bda2c73cd6ef67d56b733b357cea384185b3022bd09f05e002cd144ca
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml uv.lock ./
|
||||
|
||||
@@ -2,6 +2,7 @@ use tauri::{AppHandle, Emitter, Manager, RunEvent, WindowEvent};
|
||||
|
||||
mod utils;
|
||||
pub mod commands;
|
||||
mod menu;
|
||||
mod state;
|
||||
|
||||
use commands::{
|
||||
@@ -74,6 +75,12 @@ fn parse_launch_files(args: &[String]) -> Vec<String> {
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.menu(menu::build_app_menu)
|
||||
.on_menu_event(|app, event| {
|
||||
if event.id() == menu::GRACEFUL_QUIT_MENU_ID {
|
||||
menu::request_graceful_quit(app);
|
||||
}
|
||||
})
|
||||
.plugin(
|
||||
tauri_plugin_log::Builder::new()
|
||||
.level(log::LevelFilter::Info)
|
||||
@@ -209,6 +216,10 @@ pub fn run() {
|
||||
// Use Tauri's built-in cleanup
|
||||
app_handle.cleanup_before_exit();
|
||||
}
|
||||
RunEvent::Exit => {
|
||||
add_log("🔄 App exiting, ensuring backend cleanup...".to_string());
|
||||
cleanup_backend();
|
||||
}
|
||||
RunEvent::WindowEvent { event: WindowEvent::CloseRequested {.. }, .. } => {
|
||||
add_log("🔄 Window close requested (will cleanup on actual exit)...".to_string());
|
||||
// Don't cleanup here - let JavaScript handler prevent close if needed
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
use tauri::menu::Menu;
|
||||
use tauri::{AppHandle, Manager, Runtime};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::menu::{
|
||||
AboutMetadata, MenuItem, PredefinedMenuItem, Submenu, HELP_SUBMENU_ID, WINDOW_SUBMENU_ID,
|
||||
};
|
||||
|
||||
use crate::utils::add_log;
|
||||
|
||||
// Id of our custom Quit item. macOS routes Cmd+Q / the app-menu Quit through
|
||||
// [NSApp terminate:], which fires RunEvent::Exit (not ExitRequested) and never
|
||||
// asks windows to close - so the frontend's unsaved-changes guard is bypassed.
|
||||
// We intercept the shortcut with this item and route it through each window's
|
||||
// close flow instead.
|
||||
pub const GRACEFUL_QUIT_MENU_ID: &str = "graceful-quit";
|
||||
|
||||
// macOS: mirror Tauri's default menu (Menu::default) but replace the standard
|
||||
// Quit item with a custom one so Cmd+Q goes through request_graceful_quit().
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn build_app_menu<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<Menu<R>> {
|
||||
let pkg = app.package_info();
|
||||
let config = app.config();
|
||||
let about = AboutMetadata {
|
||||
name: Some(pkg.name.clone()),
|
||||
version: Some(pkg.version.to_string()),
|
||||
copyright: config.bundle.copyright.clone(),
|
||||
authors: config.bundle.publisher.clone().map(|p| vec![p]),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let quit = MenuItem::with_id(
|
||||
app,
|
||||
GRACEFUL_QUIT_MENU_ID,
|
||||
format!("Quit {}", pkg.name),
|
||||
true,
|
||||
Some("CmdOrCtrl+Q"),
|
||||
)?;
|
||||
|
||||
let app_menu = Submenu::with_items(
|
||||
app,
|
||||
pkg.name.clone(),
|
||||
true,
|
||||
&[
|
||||
&PredefinedMenuItem::about(app, None, Some(about))?,
|
||||
&PredefinedMenuItem::separator(app)?,
|
||||
&PredefinedMenuItem::services(app, None)?,
|
||||
&PredefinedMenuItem::separator(app)?,
|
||||
&PredefinedMenuItem::hide(app, None)?,
|
||||
&PredefinedMenuItem::hide_others(app, None)?,
|
||||
&PredefinedMenuItem::separator(app)?,
|
||||
&quit,
|
||||
],
|
||||
)?;
|
||||
|
||||
let file_menu = Submenu::with_items(
|
||||
app,
|
||||
"File",
|
||||
true,
|
||||
&[&PredefinedMenuItem::close_window(app, None)?],
|
||||
)?;
|
||||
|
||||
let edit_menu = Submenu::with_items(
|
||||
app,
|
||||
"Edit",
|
||||
true,
|
||||
&[
|
||||
&PredefinedMenuItem::undo(app, None)?,
|
||||
&PredefinedMenuItem::redo(app, None)?,
|
||||
&PredefinedMenuItem::separator(app)?,
|
||||
&PredefinedMenuItem::cut(app, None)?,
|
||||
&PredefinedMenuItem::copy(app, None)?,
|
||||
&PredefinedMenuItem::paste(app, None)?,
|
||||
&PredefinedMenuItem::select_all(app, None)?,
|
||||
],
|
||||
)?;
|
||||
|
||||
let view_menu = Submenu::with_items(
|
||||
app,
|
||||
"View",
|
||||
true,
|
||||
&[&PredefinedMenuItem::fullscreen(app, None)?],
|
||||
)?;
|
||||
|
||||
let window_menu = Submenu::with_id_and_items(
|
||||
app,
|
||||
WINDOW_SUBMENU_ID,
|
||||
"Window",
|
||||
true,
|
||||
&[
|
||||
&PredefinedMenuItem::minimize(app, None)?,
|
||||
&PredefinedMenuItem::maximize(app, None)?,
|
||||
&PredefinedMenuItem::separator(app)?,
|
||||
&PredefinedMenuItem::close_window(app, None)?,
|
||||
],
|
||||
)?;
|
||||
|
||||
let help_menu = Submenu::with_id_and_items(app, HELP_SUBMENU_ID, "Help", true, &[])?;
|
||||
|
||||
Menu::with_items(
|
||||
app,
|
||||
&[
|
||||
&app_menu,
|
||||
&file_menu,
|
||||
&edit_menu,
|
||||
&view_menu,
|
||||
&window_menu,
|
||||
&help_menu,
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
// Other platforms keep Tauri's default menu unchanged; the RunEvent::Exit
|
||||
// cleanup path in lib.rs already guards against orphaned backends there.
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn build_app_menu<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<Menu<R>> {
|
||||
Menu::default(app)
|
||||
}
|
||||
|
||||
// Route a quit request through each window's close flow so the frontend's
|
||||
// unsaved-changes guard (useExitWarning) runs. Closing the last window causes
|
||||
// the runtime to emit RunEvent::ExitRequested, which kills the bundled backend.
|
||||
// If somehow no windows exist, exit directly.
|
||||
pub fn request_graceful_quit<R: Runtime>(app: &AppHandle<R>) {
|
||||
let windows = app.webview_windows();
|
||||
if windows.is_empty() {
|
||||
add_log("Quit requested with no open windows; exiting.".to_string());
|
||||
app.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
add_log(format!(
|
||||
"Quit requested; closing {} window(s) via close flow",
|
||||
windows.len()
|
||||
));
|
||||
for (_, window) in windows {
|
||||
let _ = window.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user