From 4cedfa070a04e8249add000cf412e3da85937251 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 23 Feb 2026 16:24:36 +0100 Subject: [PATCH] booklore v2: embed frontend, bump Java to 25, remove nginx Upgrade Java from 21 to 25 and add embedding of the built frontend into the backend resources so the Spring Boot app serves static files. Build steps now skip tests (gradle -x test). Remove nginx install/configuration paths: install script no longer installs or configures nginx; update script disables and purges nginx if active. Add default SERVER_PORT=6060 to the .env (or append if missing). Update systemd unit ExecStart to include JVM tuning flags and reload systemd. Misc: adjust start/reload steps to reflect nginx removal and clean up previous backup dirs. --- ct/booklore.sh | 24 +++++++++++++++++++++--- install/booklore-install.sh | 26 +++++++++----------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/ct/booklore.sh b/ct/booklore.sh index 003230c7b..5a5cd59e4 100644 --- a/ct/booklore.sh +++ b/ct/booklore.sh @@ -30,7 +30,7 @@ function update_script() { fi if check_for_gh_release "booklore" "booklore-app/BookLore"; then - JAVA_VERSION="21" setup_java + JAVA_VERSION="25" setup_java NODE_VERSION="22" setup_nodejs setup_mariadb setup_yq @@ -60,11 +60,16 @@ function update_script() { $STD npm run build --configuration=production msg_ok "Built Frontend" + msg_info "Embedding Frontend into Backend" + mkdir -p /opt/booklore/booklore-api/src/main/resources/static + cp -r /opt/booklore/booklore-ui/dist/booklore/browser/* /opt/booklore/booklore-api/src/main/resources/static/ + msg_ok "Embedded Frontend into Backend" + msg_info "Building Backend" cd /opt/booklore/booklore-api APP_VERSION=$(get_latest_github_release "booklore-app/BookLore") yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml - $STD ./gradlew clean build --no-daemon + $STD ./gradlew clean build -x test --no-daemon mkdir -p /opt/booklore/dist JAR_PATH=$(find /opt/booklore/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1) if [[ -z "$JAR_PATH" ]]; then @@ -74,9 +79,22 @@ function update_script() { cp "$JAR_PATH" /opt/booklore/dist/app.jar msg_ok "Built Backend" + if systemctl is-active --quiet nginx 2>/dev/null; then + msg_info "Removing Nginx (no longer needed)" + systemctl disable --now nginx + $STD apt-get purge -y nginx nginx-common + msg_ok "Removed Nginx" + fi + + if ! grep -q "^SERVER_PORT=" /opt/booklore_storage/.env 2>/dev/null; then + echo "SERVER_PORT=6060" >>/opt/booklore_storage/.env + fi + + sed -i 's|ExecStart=/usr/bin/java -jar|ExecStart=/usr/bin/java -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompactObjectHeaders -jar|' /etc/systemd/system/booklore.service + systemctl daemon-reload + msg_info "Starting Service" systemctl start booklore - systemctl reload nginx rm -rf /opt/booklore_bak msg_ok "Started Service" msg_ok "Updated successfully!" diff --git a/install/booklore-install.sh b/install/booklore-install.sh index bb800c0a5..f31da1693 100644 --- a/install/booklore-install.sh +++ b/install/booklore-install.sh @@ -13,11 +13,7 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" -$STD apt install -y nginx -msg_ok "Installed Dependencies" - -JAVA_VERSION="21" setup_java +JAVA_VERSION="25" setup_java NODE_VERSION="22" setup_nodejs setup_mariadb setup_yq @@ -30,6 +26,11 @@ $STD npm install --force $STD npm run build --configuration=production msg_ok "Built Frontend" +msg_info "Embedding Frontend into Backend" +mkdir -p /opt/booklore/booklore-api/src/main/resources/static +cp -r /opt/booklore/booklore-ui/dist/booklore/browser/* /opt/booklore/booklore-api/src/main/resources/static/ +msg_ok "Embedded Frontend into Backend" + msg_info "Creating Environment" mkdir -p /opt/booklore_storage/{data,books,bookdrop} cat </opt/booklore_storage/.env @@ -41,6 +42,7 @@ DATABASE_PASSWORD=${MARIADB_DB_PASS} # App Configuration (Spring Boot mapping from app.* properties) APP_PATH_CONFIG=/opt/booklore_storage/data APP_BOOKDROP_FOLDER=/opt/booklore_storage/bookdrop +SERVER_PORT=6060 EOF msg_ok "Created Environment" @@ -48,7 +50,7 @@ msg_info "Building Backend" cd /opt/booklore/booklore-api APP_VERSION=$(get_latest_github_release "booklore-app/BookLore") yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml -$STD ./gradlew clean build --no-daemon +$STD ./gradlew clean build -x test --no-daemon mkdir -p /opt/booklore/dist JAR_PATH=$(find /opt/booklore/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1) if [[ -z "$JAR_PATH" ]]; then @@ -58,16 +60,6 @@ fi cp "$JAR_PATH" /opt/booklore/dist/app.jar msg_ok "Built Backend" -msg_info "Configuring Nginx" -rm -rf /usr/share/nginx/html -ln -s /opt/booklore/booklore-ui/dist/booklore/browser /usr/share/nginx/html -rm -f /etc/nginx/sites-enabled/default -cp /opt/booklore/nginx.conf /etc/nginx/nginx.conf -sed -i 's/listen \${BOOKLORE_PORT};/listen 6060;/' /etc/nginx/nginx.conf -sed -i 's/listen \[::\]:${BOOKLORE_PORT};/listen [::]:6060;/' /etc/nginx/nginx.conf -systemctl restart nginx -msg_ok "Configured Nginx" - msg_info "Creating Service" cat </etc/systemd/system/booklore.service [Unit] @@ -78,7 +70,7 @@ After=network.target mariadb.service Type=simple User=root WorkingDirectory=/opt/booklore/dist -ExecStart=/usr/bin/java -jar /opt/booklore/dist/app.jar +ExecStart=/usr/bin/java -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompactObjectHeaders -jar /opt/booklore/dist/app.jar EnvironmentFile=/opt/booklore_storage/.env SuccessExitStatus=143 TimeoutStopSec=10