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