移除docker部署相关文件,更新readme和开发文档
This commit is contained in:
@@ -1,43 +0,0 @@
|
|||||||
# Git
|
|
||||||
.git/
|
|
||||||
.gitignore
|
|
||||||
.gitattributes
|
|
||||||
|
|
||||||
# IDE
|
|
||||||
.idea/
|
|
||||||
.vscode/
|
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
|
|
||||||
# Maven
|
|
||||||
**/target/
|
|
||||||
.mvn/
|
|
||||||
|
|
||||||
# Node
|
|
||||||
**/node_modules/
|
|
||||||
**/dist/
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# OS
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# Docs
|
|
||||||
*.md
|
|
||||||
!README.md
|
|
||||||
LICENSE
|
|
||||||
|
|
||||||
# Env (keep .env but not local overrides)
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Temp
|
|
||||||
tmp/
|
|
||||||
temp/
|
|
||||||
*.tmp
|
|
||||||
|
|
||||||
# Deploy package
|
|
||||||
weather-data-deploy/
|
|
||||||
weather-data-deploy.tar.gz
|
|
||||||
@@ -54,14 +54,8 @@ npm run build # production build
|
|||||||
npm run lint # ESLint on src/**/*.{vue,ts}
|
npm run lint # ESLint on src/**/*.{vue,ts}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker Compose
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose up -d # MySQL + Redis + admin + api + UI + nginx gateway
|
|
||||||
```
|
|
||||||
|
|
||||||
## Key Configuration
|
## Key Configuration
|
||||||
|
|
||||||
- **Dev profile**: `system-admin/src/main/resources/application-dev.yml` -- local MySQL (weather_data_system), Redis 127.0.0.1:6379
|
- **Dev profile**: `system-admin/src/main/resources/application-dev.yml` -- local MySQL (weather_data_system), Redis 127.0.0.1:6379
|
||||||
- **Prod profile**: `application-prod.yml` -- expects env variables for DB/Redis (see docker-compose.yml)
|
- **Prod profile**: `application-prod.yml` -- production configuration with external DB/Redis
|
||||||
- **project-options.redis.open**: toggles Redis caching globally (set via sys_params)
|
- **project-options.redis.open**: toggles Redis caching globally (set via sys_params)
|
||||||
|
|||||||
@@ -1,191 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and
|
|
||||||
distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
||||||
owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
||||||
that control, are controlled by, or are under common control with that entity.
|
|
||||||
For the purposes of this definition, "control" means (i) the power, direct or
|
|
||||||
indirect, to cause the direction or management of such entity, whether by
|
|
||||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
||||||
permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications, including
|
|
||||||
but not limited to software source code, documentation source, and configuration
|
|
||||||
files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical transformation or
|
|
||||||
translation of a Source form, including but not limited to compiled object code,
|
|
||||||
generated documentation, and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
||||||
available under the License, as indicated by a copyright notice that is included
|
|
||||||
in or attached to the work (an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
||||||
is based on (or derived from) the Work and for which the editorial revisions,
|
|
||||||
annotations, elaborations, or other modifications represent, as a whole, an
|
|
||||||
original work of authorship. For the purposes of this License, Derivative Works
|
|
||||||
shall not include works that remain separable from, or merely link (or bind by
|
|
||||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including the original version
|
|
||||||
of the Work and any modifications or additions to that Work or Derivative Works
|
|
||||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
||||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
||||||
on behalf of the copyright owner. For the purposes of this definition,
|
|
||||||
"submitted" means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems, and
|
|
||||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
||||||
the purpose of discussing and improving the Work, but excluding communication
|
|
||||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
||||||
owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
||||||
of whom a Contribution has been received by Licensor and subsequently
|
|
||||||
incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License.
|
|
||||||
|
|
||||||
Subject to the terms and conditions of this License, each Contributor hereby
|
|
||||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
||||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
||||||
Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License.
|
|
||||||
|
|
||||||
Subject to the terms and conditions of this License, each Contributor hereby
|
|
||||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
||||||
irrevocable (except as stated in this section) patent license to make, have
|
|
||||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
||||||
such license applies only to those patent claims licensable by such Contributor
|
|
||||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
||||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
||||||
submitted. If You institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
||||||
Contribution incorporated within the Work constitutes direct or contributory
|
|
||||||
patent infringement, then any patent licenses granted to You under this License
|
|
||||||
for that Work shall terminate as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution.
|
|
||||||
|
|
||||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
||||||
in any medium, with or without modifications, and in Source or Object form,
|
|
||||||
provided that You meet the following conditions:
|
|
||||||
|
|
||||||
You must give any other recipients of the Work or Derivative Works a copy of
|
|
||||||
this License; and
|
|
||||||
You must cause any modified files to carry prominent notices stating that You
|
|
||||||
changed the files; and
|
|
||||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
|
||||||
all copyright, patent, trademark, and attribution notices from the Source form
|
|
||||||
of the Work, excluding those notices that do not pertain to any part of the
|
|
||||||
Derivative Works; and
|
|
||||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
|
||||||
Derivative Works that You distribute must include a readable copy of the
|
|
||||||
attribution notices contained within such NOTICE file, excluding those notices
|
|
||||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
||||||
following places: within a NOTICE text file distributed as part of the
|
|
||||||
Derivative Works; within the Source form or documentation, if provided along
|
|
||||||
with the Derivative Works; or, within a display generated by the Derivative
|
|
||||||
Works, if and wherever such third-party notices normally appear. The contents of
|
|
||||||
the NOTICE file are for informational purposes only and do not modify the
|
|
||||||
License. You may add Your own attribution notices within Derivative Works that
|
|
||||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
||||||
provided that such additional attribution notices cannot be construed as
|
|
||||||
modifying the License.
|
|
||||||
You may add Your own copyright statement to Your modifications and may provide
|
|
||||||
additional or different license terms and conditions for use, reproduction, or
|
|
||||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
||||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
||||||
with the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions.
|
|
||||||
|
|
||||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
||||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
||||||
conditions of this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
||||||
any separate license agreement you may have executed with Licensor regarding
|
|
||||||
such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks.
|
|
||||||
|
|
||||||
This License does not grant permission to use the trade names, trademarks,
|
|
||||||
service marks, or product names of the Licensor, except as required for
|
|
||||||
reasonable and customary use in describing the origin of the Work and
|
|
||||||
reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
||||||
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
||||||
including, without limitation, any warranties or conditions of TITLE,
|
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
||||||
solely responsible for determining the appropriateness of using or
|
|
||||||
redistributing the Work and assume any risks associated with Your exercise of
|
|
||||||
permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability.
|
|
||||||
|
|
||||||
In no event and under no legal theory, whether in tort (including negligence),
|
|
||||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
||||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special, incidental,
|
|
||||||
or consequential damages of any character arising as a result of this License or
|
|
||||||
out of the use or inability to use the Work (including but not limited to
|
|
||||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
||||||
any and all other commercial damages or losses), even if such Contributor has
|
|
||||||
been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability.
|
|
||||||
|
|
||||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
||||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
||||||
other liability obligations and/or rights consistent with this License. However,
|
|
||||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
||||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
||||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason of your
|
|
||||||
accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following boilerplate
|
|
||||||
notice, with the fields enclosed by brackets "{}" replaced with your own
|
|
||||||
identifying information. (Don't include the brackets!) The text should be
|
|
||||||
enclosed in the appropriate comment syntax for the file format. We also
|
|
||||||
recommend that a file or class name and description of purpose be included on
|
|
||||||
the same "printed page" as the copyright notice for easier identification within
|
|
||||||
third-party archives.
|
|
||||||
|
|
||||||
Copyright 2018 人人开源
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
@@ -117,25 +117,11 @@ Edit `weather-data-ui/.env.development` and set `VITE_APP_API` to your backend U
|
|||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
### Docker Compose
|
1. Build backend: `mvn clean package -DskipTests -f system-admin`
|
||||||
|
2. Build frontend: `cd weather-data-ui && npm run build`
|
||||||
```bash
|
3. Deploy `system-admin/target/system-admin.jar` and `weather-data-ui/dist/` to server
|
||||||
# Build backend JARs and frontend dist
|
4. Configure `application-prod.yml` with production DB/Redis settings
|
||||||
mvn clean install -DskipTests
|
5. Start backend: `java -jar system-admin.jar --spring.profiles.active=prod`
|
||||||
cd weather-data-ui && npm run build && cd ..
|
|
||||||
|
|
||||||
# Configure environment
|
|
||||||
cp .env .env.local # Edit passwords in .env.local
|
|
||||||
|
|
||||||
# Start all services
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# Access
|
|
||||||
# http://localhost -> Frontend (via nginx gateway)
|
|
||||||
# http://localhost:8080 -> Admin backend
|
|
||||||
```
|
|
||||||
|
|
||||||
Services: MySQL 8.0, Redis 7, Admin (Spring Boot), API (optional, port 8081), UI (nginx), Gateway (nginx reverse proxy, port 80).
|
|
||||||
|
|
||||||
### Windows Server
|
### Windows Server
|
||||||
|
|
||||||
@@ -151,7 +137,3 @@ See `deploy/` directory for one-click deployment scripts (`deploy.bat` / `deploy
|
|||||||
- **Dynamic datasource**: Runtime datasource switching via `@DataSource` annotation with ThreadLocal context
|
- **Dynamic datasource**: Runtime datasource switching via `@DataSource` annotation with ThreadLocal context
|
||||||
- **Job scheduling**: Quartz-based dynamic job management with online start/stop/configure
|
- **Job scheduling**: Quartz-based dynamic job management with online start/stop/configure
|
||||||
- **Cloud storage**: Alibaba Cloud OSS, Qiniu, Tencent Cloud COS integration
|
- **Cloud storage**: Alibaba Cloud OSS, Qiniu, Tencent Cloud COS integration
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Apache License 2.0
|
|
||||||
|
|||||||
+5
-25
@@ -119,27 +119,11 @@ npm run dev
|
|||||||
|
|
||||||
## 部署
|
## 部署
|
||||||
|
|
||||||
### Docker Compose
|
1. 构建后端:`mvn clean package -DskipTests -f system-admin`
|
||||||
|
2. 构建前端:`cd weather-data-ui && npm run build`
|
||||||
编排文件:[docker-compose.yml](docker-compose.yml)
|
3. 将 `system-admin/target/system-admin.jar` 和 `weather-data-ui/dist/` 部署到服务器
|
||||||
|
4. 配置 `application-prod.yml` 中的生产环境数据库和 Redis 连接信息
|
||||||
```bash
|
5. 启动后端:`java -jar system-admin.jar --spring.profiles.active=prod`
|
||||||
# 构建后端 JAR 和前端产物
|
|
||||||
mvn clean install -DskipTests
|
|
||||||
cd weather-data-ui && npm run build && cd ..
|
|
||||||
|
|
||||||
# 配置环境变量
|
|
||||||
cp .env .env.local # 在 .env.local 中修改密码等敏感配置
|
|
||||||
|
|
||||||
# 启动所有服务
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# 访问地址
|
|
||||||
# http://localhost -> 前端页面(通过 nginx 网关)
|
|
||||||
# http://localhost:8080 -> 管理后台
|
|
||||||
```
|
|
||||||
|
|
||||||
服务清单:MySQL 8.0、Redis 7、Admin(Spring Boot)、API(可选,端口 8081)、UI(nginx)、Gateway(nginx 反向代理,端口 80)。
|
|
||||||
|
|
||||||
### Windows Server
|
### Windows Server
|
||||||
|
|
||||||
@@ -155,7 +139,3 @@ docker compose up -d
|
|||||||
- **动态数据源**:运行时通过 `@DataSource` 注解切换数据源,ThreadLocal 上下文传递。实现:[DynamicDataSource](system-dynamic-datasource/src/main/java/com/weather/commons/dynamic/datasource/config/DynamicDataSource.java)
|
- **动态数据源**:运行时通过 `@DataSource` 注解切换数据源,ThreadLocal 上下文传递。实现:[DynamicDataSource](system-dynamic-datasource/src/main/java/com/weather/commons/dynamic/datasource/config/DynamicDataSource.java)
|
||||||
- **定时任务**:Quartz 动态任务管理,支持在线创建、启停、修改 Cron 表达式。配置:[ScheduleConfig](system-admin/src/main/java/com/weather/modules/job/config/ScheduleConfig.java)
|
- **定时任务**:Quartz 动态任务管理,支持在线创建、启停、修改 Cron 表达式。配置:[ScheduleConfig](system-admin/src/main/java/com/weather/modules/job/config/ScheduleConfig.java)
|
||||||
- **云存储**:支持阿里云 OSS、七牛云、腾讯云 COS 文件上传与管理。工厂:[OSSFactory](system-admin/src/main/java/com/weather/modules/oss/cloud/OSSFactory.java)
|
- **云存储**:支持阿里云 OSS、七牛云、腾讯云 COS 文件上传与管理。工厂:[OSSFactory](system-admin/src/main/java/com/weather/modules/oss/cloud/OSSFactory.java)
|
||||||
|
|
||||||
## 许可证
|
|
||||||
|
|
||||||
[Apache License 2.0](LICENSE)
|
|
||||||
|
|||||||
@@ -1,204 +0,0 @@
|
|||||||
# ============================================================
|
|
||||||
# Weather Data System - Docker Compose 部署编排
|
|
||||||
#
|
|
||||||
# 前置条件:
|
|
||||||
# 1. 安装 Docker Engine 20.10+ 和 Docker Compose v2
|
|
||||||
# 2. 复制 .env 文件并修改配置
|
|
||||||
# 3. 确保 JAR 文件已构建到对应 target/ 目录
|
|
||||||
# 4. 确保前端已构建到 weather-data-ui/dist/
|
|
||||||
#
|
|
||||||
# 启动: docker compose up -d
|
|
||||||
# 停止: docker compose down
|
|
||||||
# 日志: docker compose logs -f [服务名]
|
|
||||||
# ============================================================
|
|
||||||
|
|
||||||
services:
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# MySQL 数据库
|
|
||||||
# ==========================================================
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: weather-mysql
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
|
||||||
MYSQL_DATABASE: ${MYSQL_DATABASE:-weather_data_system}
|
|
||||||
MYSQL_USER: ${MYSQL_USER:-weather}
|
|
||||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
|
||||||
TZ: Asia/Shanghai
|
|
||||||
ports:
|
|
||||||
- "${MYSQL_PORT:-3306}:3306"
|
|
||||||
volumes:
|
|
||||||
- mysql-data:/var/lib/mysql
|
|
||||||
- ./deploy/mysql/init:/docker-entrypoint-initdb.d:ro # 初始化 SQL
|
|
||||||
command:
|
|
||||||
- --character-set-server=utf8mb4
|
|
||||||
- --collation-server=utf8mb4_unicode_ci
|
|
||||||
- --default-time-zone=+08:00
|
|
||||||
- --max-allowed-packet=128M
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 10
|
|
||||||
start_period: 60s
|
|
||||||
networks:
|
|
||||||
- weather-net
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# Redis 缓存
|
|
||||||
# ==========================================================
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
container_name: weather-redis
|
|
||||||
restart: unless-stopped
|
|
||||||
command:
|
|
||||||
- redis-server
|
|
||||||
- --appendonly yes
|
|
||||||
- --requirepass ${REDIS_PASSWORD}
|
|
||||||
ports:
|
|
||||||
- "${REDIS_PORT:-6379}:6379"
|
|
||||||
volumes:
|
|
||||||
- redis-data:/data
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
networks:
|
|
||||||
- weather-net
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# 管理后台 (Spring Boot Admin)
|
|
||||||
# ==========================================================
|
|
||||||
admin:
|
|
||||||
build:
|
|
||||||
context: ./system-admin
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: weather-data-admin:${APP_VERSION:-latest}
|
|
||||||
container_name: weather-admin
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
mysql:
|
|
||||||
condition: service_healthy
|
|
||||||
redis:
|
|
||||||
condition: service_healthy
|
|
||||||
environment:
|
|
||||||
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
|
|
||||||
JAVA_OPTS: ${JAVA_OPTS:--Xms256m -Xmx512m -XX:+UseG1GC}
|
|
||||||
TZ: Asia/Shanghai
|
|
||||||
# 覆盖 application.yml 中的数据库/Redis 配置
|
|
||||||
SPRING_DATASOURCE_DRUID_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE:-weather_data_system}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
|
||||||
SPRING_DATASOURCE_DRUID_USERNAME: ${MYSQL_USER:-weather}
|
|
||||||
SPRING_DATASOURCE_DRUID_PASSWORD: ${MYSQL_PASSWORD}
|
|
||||||
SPRING_DATA_REDIS_HOST: redis
|
|
||||||
SPRING_DATA_REDIS_PORT: 6379
|
|
||||||
SPRING_DATA_REDIS_PASSWORD: ${REDIS_PASSWORD}
|
|
||||||
ports:
|
|
||||||
- "${ADMIN_PORT:-8080}:8080"
|
|
||||||
volumes:
|
|
||||||
- admin-logs:/app/logs
|
|
||||||
- admin-uploads:/app/upload
|
|
||||||
networks:
|
|
||||||
- weather-net
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# API 服务
|
|
||||||
# ==========================================================
|
|
||||||
api:
|
|
||||||
build:
|
|
||||||
context: ./system-api
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: weather-data-api:${APP_VERSION:-latest}
|
|
||||||
container_name: weather-api
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
mysql:
|
|
||||||
condition: service_healthy
|
|
||||||
redis:
|
|
||||||
condition: service_healthy
|
|
||||||
environment:
|
|
||||||
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
|
|
||||||
JAVA_OPTS: ${JAVA_OPTS:--Xms256m -Xmx512m -XX:+UseG1GC}
|
|
||||||
TZ: Asia/Shanghai
|
|
||||||
SPRING_DATASOURCE_DRUID_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE:-weather_data_system}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
|
||||||
SPRING_DATASOURCE_DRUID_USERNAME: ${MYSQL_USER:-weather}
|
|
||||||
SPRING_DATASOURCE_DRUID_PASSWORD: ${MYSQL_PASSWORD}
|
|
||||||
SPRING_DATA_REDIS_HOST: redis
|
|
||||||
SPRING_DATA_REDIS_PORT: 6379
|
|
||||||
SPRING_DATA_REDIS_PASSWORD: ${REDIS_PASSWORD}
|
|
||||||
ports:
|
|
||||||
- "${API_PORT:-8081}:8081"
|
|
||||||
volumes:
|
|
||||||
- api-logs:/app/logs
|
|
||||||
- api-uploads:/app/upload
|
|
||||||
networks:
|
|
||||||
- weather-net
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# 前端 UI
|
|
||||||
# ==========================================================
|
|
||||||
ui:
|
|
||||||
build:
|
|
||||||
context: ./weather-data-ui
|
|
||||||
dockerfile: ${UI_DOCKERFILE:-Dockerfile.offline}
|
|
||||||
image: weather-data-ui:${APP_VERSION:-latest}
|
|
||||||
container_name: weather-ui
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
- admin
|
|
||||||
- api
|
|
||||||
networks:
|
|
||||||
- weather-net
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# Gateway - 统一入口 Nginx 反向代理
|
|
||||||
# ==========================================================
|
|
||||||
gateway:
|
|
||||||
image: nginx:alpine
|
|
||||||
container_name: weather-gateway
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
- ui
|
|
||||||
- admin
|
|
||||||
- api
|
|
||||||
ports:
|
|
||||||
- "${GATEWAY_PORT:-80}:80"
|
|
||||||
volumes:
|
|
||||||
- ./deploy/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
- gateway-logs:/var/log/nginx
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "-qO-", "http://localhost/"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 3
|
|
||||||
networks:
|
|
||||||
- weather-net
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 数据卷 (持久化存储)
|
|
||||||
# ============================================================
|
|
||||||
volumes:
|
|
||||||
mysql-data:
|
|
||||||
name: weather-mysql-data
|
|
||||||
redis-data:
|
|
||||||
name: weather-redis-data
|
|
||||||
admin-logs:
|
|
||||||
name: weather-admin-logs
|
|
||||||
admin-uploads:
|
|
||||||
name: weather-admin-uploads
|
|
||||||
api-logs:
|
|
||||||
name: weather-api-logs
|
|
||||||
api-uploads:
|
|
||||||
name: weather-api-uploads
|
|
||||||
gateway-logs:
|
|
||||||
name: weather-gateway-logs
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 网络
|
|
||||||
# ============================================================
|
|
||||||
networks:
|
|
||||||
weather-net:
|
|
||||||
name: weather-net
|
|
||||||
driver: bridge
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
FROM eclipse-temurin:17-jre-alpine
|
|
||||||
|
|
||||||
LABEL maintainer="weather-data"
|
|
||||||
LABEL description="Weather Data System - Admin Service"
|
|
||||||
|
|
||||||
RUN apk add --no-cache tzdata curl && \
|
|
||||||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
||||||
echo "Asia/Shanghai" > /etc/timezone
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
ARG JAR_FILE=target/system-admin.jar
|
|
||||||
COPY ${JAR_FILE} /app/app.jar
|
|
||||||
|
|
||||||
ENV JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -Djava.security.egd=file:/dev/./urandom"
|
|
||||||
ENV SPRING_PROFILES_ACTIVE=prod
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=60s \
|
|
||||||
CMD curl -f http://localhost:8080/system-admin/actuator/health || exit 1
|
|
||||||
|
|
||||||
ENTRYPOINT exec java ${JAVA_OPTS} -jar /app/app.jar
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# Dependencies
|
|
||||||
node_modules/
|
|
||||||
.pnp
|
|
||||||
.pnp.js
|
|
||||||
|
|
||||||
# Build output
|
|
||||||
dist/
|
|
||||||
|
|
||||||
# IDE
|
|
||||||
.idea/
|
|
||||||
.vscode/
|
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
|
|
||||||
# Git
|
|
||||||
.git/
|
|
||||||
.gitignore
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
|
|
||||||
# OS
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# Env files
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Test
|
|
||||||
coverage/
|
|
||||||
|
|
||||||
# Misc
|
|
||||||
*.md
|
|
||||||
!README.md
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
# ============================================================
|
|
||||||
# 多阶段构建 (开发机有网络时使用)
|
|
||||||
# docker build -t weather-data-ui .
|
|
||||||
# ============================================================
|
|
||||||
FROM node:20-alpine AS builder
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# 安装依赖
|
|
||||||
COPY package.json package-lock.json* ./
|
|
||||||
RUN npm ci --registry=https://registry.npmmirror.com
|
|
||||||
|
|
||||||
# 复制源码并构建
|
|
||||||
COPY . .
|
|
||||||
RUN npm run build:prod
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 运行阶段 - Nginx 提供静态文件服务
|
|
||||||
# ============================================================
|
|
||||||
FROM nginx:alpine
|
|
||||||
|
|
||||||
LABEL maintainer="weather-data"
|
|
||||||
LABEL description="Weather Data System - Frontend UI"
|
|
||||||
|
|
||||||
# 删除默认配置
|
|
||||||
RUN rm -f /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
# 复制自定义 nginx 配置
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
# 复制构建产物
|
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
||||||
CMD wget -qO- http://localhost/ || exit 1
|
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# ============================================================
|
|
||||||
# 离线部署 Dockerfile (内网服务器使用)
|
|
||||||
# 前提:已将 dist/ 目录拷贝到当前路径
|
|
||||||
# docker build -f Dockerfile.offline -t weather-data-ui .
|
|
||||||
# ============================================================
|
|
||||||
FROM nginx:alpine
|
|
||||||
|
|
||||||
LABEL maintainer="weather-data"
|
|
||||||
LABEL description="Weather Data System - Frontend UI (offline)"
|
|
||||||
|
|
||||||
RUN rm -f /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
COPY dist /usr/share/nginx/html
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
||||||
CMD wget -qO- http://localhost/ || exit 1
|
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name localhost;
|
|
||||||
|
|
||||||
charset utf-8;
|
|
||||||
|
|
||||||
# 访问日志 (生产环境可关闭 access_log 减少 IO)
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
error_log /var/log/nginx/error.log warn;
|
|
||||||
|
|
||||||
# 站点根目录
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# SPA 路由处理:所有非静态资源请求返回 index.html
|
|
||||||
# 因为前端使用 hash router,这里主要是兜底
|
|
||||||
# ============================================================
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 静态资源缓存策略
|
|
||||||
# /assets/ 下的文件经过 Vite 处理带有 content hash,可长期缓存
|
|
||||||
# ============================================================
|
|
||||||
location /assets/ {
|
|
||||||
expires 1y;
|
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
access_log off;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# index.html 禁止缓存(确保前端更新后立即生效)
|
|
||||||
# ============================================================
|
|
||||||
location = /index.html {
|
|
||||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
||||||
add_header Pragma "no-cache";
|
|
||||||
add_header Expires 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# Gzip 压缩
|
|
||||||
# ============================================================
|
|
||||||
gzip on;
|
|
||||||
gzip_vary on;
|
|
||||||
gzip_proxied any;
|
|
||||||
gzip_comp_level 6;
|
|
||||||
gzip_min_length 1024;
|
|
||||||
gzip_types
|
|
||||||
text/plain
|
|
||||||
text/css
|
|
||||||
text/xml
|
|
||||||
text/javascript
|
|
||||||
application/javascript
|
|
||||||
application/json
|
|
||||||
application/xml
|
|
||||||
image/svg+xml;
|
|
||||||
|
|
||||||
# 隐藏 Nginx 版本号
|
|
||||||
server_tokens off;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user