From 9b6e188df84a0addb22605ab1a6867a4c2799dc1 Mon Sep 17 00:00:00 2001 From: "NAS\\NASPC" Date: Tue, 9 Jun 2026 08:09:51 +0700 Subject: [PATCH] =?UTF-8?q?realease=20l=E1=BA=A7n=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sisvietnamvn/README.md | 101 +- sisvietnamvn/apply_layout.js | 49 - sisvietnamvn/build.gradle | 2 +- sisvietnamvn/build.ps1 | 1 + sisvietnamvn/fix_about_links.js | 14 - sisvietnamvn/fix_images.ps1 | 5 - sisvietnamvn/src/main/docker/oracle.yml | 18 + .../src/main/resources/static/css/custom.css | 24 + .../src/main/resources/static/css/style.css | 479 +- ...RfkAM8YF5Q0QWY1kViexTYtKJcgG2xJuC-39x0.css | 5 +- .../resources/templates/fragments/footer.html | 2 +- .../resources/templates/fragments/header.html | 2053 ++++----- .../resources/templates/fragments/layout.html | 16 +- .../src/main/resources/templates/index.html | 3854 +++++++++-------- .../src/main/resources/templates/lien-he.html | 46 +- sisvietnamvn/sync.ps1 | 30 - sisvietnamvn/update_about.js | 25 - sisvietnamvn/update_about.ps1 | 23 - sisvietnamvn/update_index_footer.js | 9 - 19 files changed, 3638 insertions(+), 3118 deletions(-) delete mode 100644 sisvietnamvn/apply_layout.js create mode 100644 sisvietnamvn/build.ps1 delete mode 100644 sisvietnamvn/fix_about_links.js delete mode 100644 sisvietnamvn/fix_images.ps1 create mode 100644 sisvietnamvn/src/main/docker/oracle.yml create mode 100644 sisvietnamvn/src/main/resources/static/css/custom.css delete mode 100644 sisvietnamvn/sync.ps1 delete mode 100644 sisvietnamvn/update_about.js delete mode 100644 sisvietnamvn/update_about.ps1 delete mode 100644 sisvietnamvn/update_index_footer.js diff --git a/sisvietnamvn/README.md b/sisvietnamvn/README.md index 86dad935..316de5c0 100644 --- a/sisvietnamvn/README.md +++ b/sisvietnamvn/README.md @@ -186,67 +186,82 @@ To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`) - [Node.js](https://nodejs.org/) - [NPM](https://www.npmjs.com/) -## Deployment Guide (Ubuntu server + aaPanel + Docker) +## Deployment Guide (Ubuntu server + aaPanel + Executable JAR) -### 1. Build the WAR file (on Windows) -To deploy this application to an external Tomcat server, you need to build a `.war` file. -Run the following command on your Windows PC to build the production-ready `.war` file: +### 1. Build the JAR file (on Windows) +Spring Boot applications come with a built-in web server, meaning you can package your entire application into a single executable `.jar` file! +Run the following command on your Windows PC to build the production-ready `.jar` file: ```powershell -./gradlew -Pprod -Pwar clean bootWar +./gradlew -Pprod clean bootJar ``` Alternatively, you can use the built-in npm script: ```powershell -npm run java:war:prod +npm run java:jar:prod ``` -The generated `.war` file will be located at `build/libs/sisvietnamvn-0.0.1-SNAPSHOT.war`. +The generated `.jar` file will be located at `build/libs/sisvietnamvn-1.0.3.jar`. -### 2. Standalone Tomcat 10 using Docker Compose (on Ubuntu Server) -Since this project uses Java 21, it requires **Tomcat 10.1**. You can set this up on your Ubuntu server using Docker Compose. +### 2. Deploy and Run the application (on Ubuntu Server) -Create a folder for Tomcat, and add a `docker-compose.yml` file: -```yaml -version: '3.8' +You have two main options to run the application on Ubuntu: using **aaPanel** or using standard **systemd**. -services: - tomcat: - image: tomcat:10.1-jdk21 - container_name: my-tomcat-server - ports: - - "8080:8080" - environment: - - TZ=Asia/Ho_Chi_Minh - volumes: - - ./webapps:/usr/local/tomcat/webapps - - ./logs:/usr/local/tomcat/logs - restart: unless-stopped -``` +#### Option A: Using aaPanel (Recommended) +If you are using aaPanel, it is highly recommended to use its built-in **Java Project** manager to easily run the JAR file. -Create the required folders and start the server: -```bash -mkdir webapps logs -docker compose up -d -``` +1. **Install Java 21**: Make sure Java 21 is installed on your Ubuntu server via aaPanel. +2. **Upload the JAR**: Upload the `sisvietnamvn-1.0.3.jar` file to a folder on your server (e.g., `/www/wwwroot/sisvietnam.vn/`). +3. **Add Java Project**: In aaPanel, go to **Website** -> **Java Project** -> **Add Java project**. +4. **Configure Project**: + - **Project Type**: `Spring_boot` + - **Project jar**: Select the `sisvietnamvn-1.0.3.jar` file you just uploaded. + - **Project Port**: `8080` (or whichever port your app is configured to use). + - **Run user**: `www` (or `root`) + - Click **Submit**. aaPanel will automatically run your JAR file in the background! -### 3. Deploy the application -After running the build command successfully, your .war file is located here: -d:\website_sisvietnam_moi\website_sisvietnam.vn\sisvietnamvn\build\libs\sisvietnamvn-0.0.1-SNAPSHOT.war -(Inside your project folder, look for the build folder, then open the libs folder). -This sisvietnamvn-0.0.1-SNAPSHOT.war file is the one you need to upload to your Ubuntu server and rename to ROOT.war inside the Tomcat webapps folder. +#### Option B: Using systemd (Standard Ubuntu) +If you prefer managing the server manually via terminal, you can register the JAR as a `systemd` service so it runs continuously in the background and starts automatically on boot. -Upload the `.war` file you built in Step 1 to the server. -Place it inside the `webapps/` folder you just created and rename it to `ROOT.war` (so it serves on the root path `/`). Tomcat will automatically detect and deploy it. +1. **Upload the JAR**: Upload the `sisvietnamvn-1.0.3.jar` file to your server (e.g., `/var/www/sisvietnam/sisvietnamvn.jar`). +2. **Create the Service File**: + ```bash + sudo nano /etc/systemd/system/sisvietnam.service + ``` +3. **Add Configuration**: Paste the following, making sure the `ExecStart` path matches where you put the jar. + ```ini + [Unit] + Description=SIS Vietnam Spring Boot Application + After=syslog.target network.target -### 4. Configure NGINX Reverse Proxy (aaPanel) -Using NGINX (via aaPanel) with Tomcat is a highly recommended setup. NGINX acts as a Reverse Proxy, handling internet traffic (ports 80 and 443 for SSL) and forwarding it to Tomcat on port 8080. + [Service] + User=root + ExecStart=/usr/bin/java -jar /var/www/sisvietnam/sisvietnamvn.jar + SuccessExitStatus=143 + Restart=always + RestartSec=10 + + [Install] + WantedBy=multi-user.target + ``` +4. **Start the Service**: Run the following commands to reload systemd, enable the service to start on boot, and start it now: + ```bash + sudo systemctl daemon-reload + sudo systemctl enable sisvietnam.service + sudo systemctl start sisvietnam.service + ``` +5. **Check Status & Logs**: + - To check if it's running: `sudo systemctl status sisvietnam.service` + - To view the live terminal output: `sudo journalctl -u sisvietnam.service -f` + +### 3. Configure NGINX Reverse Proxy (aaPanel) +When you set up a Java Project in aaPanel, it can automatically map your domain and set up a reverse proxy. If you need to verify or set it up manually: 1. **Add Site**: Go to aaPanel -> Website -> Add site. Enter your domain (e.g., `sisvietnam.vn`) and select **Static** for the PHP version. -2. **Setup Reverse Proxy**: Click "Settings" for the new site -> "Reverse proxy" -> "Add reverse proxy". - - **Proxy name**: `TomcatProxy` +2. **Setup Reverse Proxy**: Click "Settings" for the site -> "Reverse proxy" -> "Add reverse proxy". + - **Proxy name**: `JavaProxy` - **Target URL**: `http://127.0.0.1:8080` - **Sent Domain**: `$host` -3. **Spring Boot Proxy Trust**: Ensure Spring Boot knows it is behind a proxy so it can read client IPs and HTTP schemes correctly. In `src/main/resources/config/application-prod.yml`, verify this exists: +3. **Spring Boot Proxy Trust**: Ensure Spring Boot knows it is behind a proxy so it can read client IPs correctly. In `src/main/resources/config/application-prod.yml`, verify this exists: ```yaml server: forward-headers-strategy: framework ``` -4. **SSL**: Use aaPanel's built-in SSL manager to apply Let's Encrypt certificates to your NGINX site. Your Tomcat backend won't need to worry about SSL certificates. \ No newline at end of file +4. **SSL**: Use aaPanel's built-in SSL manager to apply Let's Encrypt certificates to your NGINX site. You don't need to configure SSL inside Spring Boot itself. \ No newline at end of file diff --git a/sisvietnamvn/apply_layout.js b/sisvietnamvn/apply_layout.js deleted file mode 100644 index 380999a8..00000000 --- a/sisvietnamvn/apply_layout.js +++ /dev/null @@ -1,49 +0,0 @@ -const fs = require('fs'); - -const aboutPath = 'd:\\website_sisvietnam_moi\\website_sisvietnam.vn\\sisvietnamvn\\src\\main\\resources\\templates\\about.html'; -const layoutPath = 'd:\\website_sisvietnam_moi\\website_sisvietnam.vn\\sisvietnamvn\\src\\main\\resources\\templates\\fragments\\layout.html'; -const footerPath = 'd:\\website_sisvietnam_moi\\website_sisvietnam.vn\\sisvietnamvn\\src\\main\\resources\\templates\\fragments\\footer.html'; - -let aboutHtml = fs.readFileSync(aboutPath, 'utf8'); -let layoutHtml = fs.readFileSync(layoutPath, 'utf8'); - -// 1. Extract Head -const headMatch = aboutHtml.match(/([\s\S]*?)<\/head>/i); -const headContent = headMatch ? headMatch[1] : ''; - -// 2. Extract Main Content (everything between and