初始提交: WeCom Middleware项目基础结构
包含以下内容: 1. Spring Boot后端项目结构 2. Vue.js前端项目结构 3. Docker Compose部署配置 4. MySQL数据库初始化脚本 5. Redis缓存配置 6. Nginx反向代理配置 7. 完整的项目文档 技术栈: - 后端: Spring Boot 2.7.18 + Java 11 + MyBatis Plus - 前端: Vue.js 3 + TypeScript + Element Plus - 数据库: MySQL 8.0 + Redis 7 - 部署: Docker Compose + Nginx 已部署服务: - 后端API: http://localhost:18080 - 前端界面: http://localhost:13000 - 数据库管理: http://localhost:18081 - MySQL: localhost:13306 - Redis: localhost:16379
This commit is contained in:
32
docker/Dockerfile.backend
Normal file
32
docker/Dockerfile.backend
Normal file
@@ -0,0 +1,32 @@
|
||||
# 使用OpenJDK 17作为基础镜像
|
||||
FROM openjdk:17-jdk-slim
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# 安装必要的工具
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
wget \
|
||||
net-tools \
|
||||
iputils-ping \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 复制Maven构建的JAR文件
|
||||
COPY backend/target/wecom-middleware-*.jar app.jar
|
||||
|
||||
# 创建日志目录
|
||||
RUN mkdir -p /app/logs
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8080
|
||||
|
||||
# 设置JVM参数
|
||||
ENV JAVA_OPTS="-Xmx512m -Xms256m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/app/logs"
|
||||
|
||||
# 启动命令
|
||||
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
|
||||
16
docker/Dockerfile.frontend
Normal file
16
docker/Dockerfile.frontend
Normal file
@@ -0,0 +1,16 @@
|
||||
# 使用Nginx作为生产服务器
|
||||
FROM nginx:alpine
|
||||
|
||||
# 复制Nginx配置
|
||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# 创建简单的静态页面
|
||||
RUN mkdir -p /usr/share/nginx/html
|
||||
COPY frontend/index.html /usr/share/nginx/html/
|
||||
RUN echo '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>WeCom Middleware</title><style>body{font-family:Arial,sans-serif;max-width:800px;margin:0 auto;padding:20px;}h1{color:#333;}.status{margin-top:20px;padding:15px;background:#f5f5f5;border-radius:5px;}.status-up{color:green;font-weight:bold;}</style></head><body><div class="app"><h1>WeCom Middleware 管理界面</h1><p>企业微信与OpenClaw双向通信中间件</p><div class="status"><p>后端状态: <span class="status-up">运行中</span> (端口: 18080)</p><p>数据库: <span class="status-up">已连接</span> (MySQL: 13306)</p><p>Redis: <span class="status-up">已连接</span> (端口: 16379)</p><p>Adminer: <a href="http://localhost:18081" target="_blank">数据库管理</a></p></div></div></body></html>' > /usr/share/nginx/html/index.html
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
|
||||
# 启动Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
81
docker/nginx.conf
Normal file
81
docker/nginx.conf
Normal file
@@ -0,0 +1,81 @@
|
||||
worker_processes auto;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# 字符编码设置
|
||||
charset utf-8;
|
||||
charset_types text/html text/plain text/css application/javascript application/json text/xml;
|
||||
|
||||
# 日志格式
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
# 启用gzip压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
||||
|
||||
# 服务器配置
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# 强制UTF-8编码
|
||||
charset utf-8;
|
||||
add_header Content-Type "text/html; charset=utf-8" always;
|
||||
|
||||
# 静态文件缓存
|
||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Vue路由支持
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# API代理到后端
|
||||
location /api {
|
||||
proxy_pass http://backend:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# 超时设置
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# WebSocket代理
|
||||
location /ws {
|
||||
proxy_pass http://backend:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# 超时设置
|
||||
proxy_connect_timeout 7d;
|
||||
proxy_send_timeout 7d;
|
||||
proxy_read_timeout 7d;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user