mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	完善:完善 README 文档开始及部署部分内容,增加 GitHub Actions 配置实现服务自动部署
This commit is contained in:
		
							
								
								
									
										50
									
								
								.github/workflows/deploy.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								.github/workflows/deploy.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| name: Deploy | ||||
|  | ||||
| on: | ||||
|   # 推送时执行 | ||||
|   push: | ||||
|     branches: [dev] | ||||
|   # pr 时执行 | ||||
|   pull_request: | ||||
|     branches: [dev] | ||||
|   # 可手动执行 | ||||
|   workflow_dispatch: | ||||
|  | ||||
| jobs: | ||||
|   deploy: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       # 1、检出源码 | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@master | ||||
|       # 2、安装 Java 环境 | ||||
|       - name: Install Java | ||||
|         uses: actions/setup-java@master | ||||
|         with: | ||||
|           distribution: 'adopt' | ||||
|           java-version: '8' | ||||
|           cache: 'maven' | ||||
|       # 3、打包 | ||||
|       - name: Build | ||||
|         run: mvn -B package -P dev --file pom.xml | ||||
|       # 4、拷贝 jar 包到服务器 | ||||
|       - name: Copy Jar | ||||
|         uses: garygrossgarten/github-action-scp@release | ||||
|         with: | ||||
|           host: ${{ secrets.SERVER_HOST }} | ||||
|           port: ${{ secrets.SERVER_PORT }} | ||||
|           username: ${{ secrets.SERVER_USERNAME }} | ||||
|           password: ${{ secrets.SERVER_PASSWORD }} | ||||
|           local: continew-admin-webapi/target/continew-admin.jar | ||||
|           remote: /docker/continew-admin/server/continew-admin.jar | ||||
|       # 5、启动后端服务 | ||||
|       - name: Start | ||||
|         uses: appleboy/ssh-action@master | ||||
|         with: | ||||
|           host: ${{ secrets.SERVER_HOST }} | ||||
|           port: ${{ secrets.SERVER_PORT }} | ||||
|           username: ${{ secrets.SERVER_USERNAME }} | ||||
|           password: ${{ secrets.SERVER_PASSWORD }} | ||||
|           script: | | ||||
|             cd /docker | ||||
|             docker-compose up --force-recreate --build -d continew-admin-server | ||||
							
								
								
									
										27
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								README.md
									
									
									
									
									
								
							| @@ -3,10 +3,37 @@ | ||||
| [](https://github.com/Charles7c/continew-admin/blob/dev/LICENSE) | ||||
|  | ||||
|  | ||||
| 📚 [在线 API 文档](http://cnadmin.charles7c.top/doc.html) | ||||
|  | ||||
| ### 简介 | ||||
|  | ||||
| ContiNew-Admin (incubating) 中后台管理框架,Continue New Admin,持续以最新流行技术栈构建。当前阶段采用的技术栈:Spring Boot、Undertow、Redis、Redisson、Hutool 等。 | ||||
|  | ||||
| ### 开始 | ||||
|  | ||||
| ```bash | ||||
| # 1.克隆本项目 | ||||
| git clone https://github.com/Charles7c/continew-admin.git | ||||
|  | ||||
| # 2.在 IDE(IntelliJ IDEA/Eclipse)中打开本项目 | ||||
|  | ||||
| # 3.修改配置文件中的 Redis 配置信息 | ||||
| # [3.也可以在 IntelliJ IDEA 中直接配置程序启动环境变量(REDIS_HOST、REDIS_PORT、REDIS_PWD、REDIS_DB)] | ||||
|  | ||||
| # 4.启动程序 | ||||
| # 4.1 启动成功:访问 http://localhost:8000/,页面输出:ContiNew-Admin backend service started successfully. | ||||
| # 4.2 接口文档:http://localhost:8000/doc.html | ||||
|  | ||||
| # 5.部署 | ||||
| # 5.1 Docker 部署 | ||||
| #   5.1.1 服务器安装好 docker 及 docker-compose(参考:https://blog.charles7c.top/categories/fragments/2022/10/31/CentOS%E5%AE%89%E8%A3%85Docker) | ||||
| #   5.1.2 执行 mvn package -P prod 进行项目打包,将 target 目录下的 continew-admin.jar 放到 /docker/continew-admin/server 目录下 | ||||
| #   5.1.3 将 docker 目录上传到服务器 / 目录下,并授权(chmod -R 777 /docker) | ||||
| #   5.1.4 修改 docker-compose.yml 中的 Redis 配置、continew-admin-server 配置、Nginx 配置 | ||||
| #   5.1.5 执行 docker-compose up -d 创建并后台运行所有容器 | ||||
| # 5.2 其他方式部署 | ||||
| ``` | ||||
|  | ||||
| ### 技术栈 | ||||
|  | ||||
| | 名称                                                         | 版本           | 简介                                                         | | ||||
|   | ||||
							
								
								
									
										11
									
								
								docker/continew-admin/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								docker/continew-admin/Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| FROM java:8 | ||||
|  | ||||
| MAINTAINER Charles7c charles7c@126.com | ||||
|  | ||||
| ARG JAR_FILE=./server/*.jar | ||||
| COPY ${JAR_FILE} app.jar | ||||
|  | ||||
| ENTRYPOINT ["java", \ | ||||
|             "-jar", \ | ||||
|             "-Djava.security.egd=file:/dev/./urandom", \ | ||||
|             "app.jar"] | ||||
							
								
								
									
										47
									
								
								docker/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								docker/docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| version: '3' | ||||
| services: | ||||
|   redis: | ||||
|     container_name: redis | ||||
|     image: redis:6.2.7 | ||||
|     restart: always | ||||
|     environment: | ||||
|       TZ: Asia/Shanghai | ||||
|     ports: | ||||
|       - '6379:6379' | ||||
|     volumes: | ||||
|       - /docker/redis/conf/redis.conf:/usr/local/redis/config/redis.conf | ||||
|       - /docker/redis/data:/data | ||||
|       - /docker/redis/logs:/logs | ||||
|     command: 'redis-server /usr/local/redis/config/redis.conf --appendonly yes --requirepass 123456' | ||||
|     privileged: true | ||||
|   continew-admin-server: | ||||
|     container_name: continew-admin-server | ||||
|     build: ./continew-admin | ||||
|     restart: always | ||||
|     environment: | ||||
|       TZ: Asia/Shanghai | ||||
|       REDIS_HOST: 172.17.0.1 | ||||
|       REDIS_PORT: 6379 | ||||
|       REDIS_PWD: 你的 Redis 密码 | ||||
|       REDIS_DB: 你的 Redis 数据库索引 | ||||
|     ports: | ||||
|       - '8000:8000' | ||||
|     volumes: | ||||
|       - /docker/continew-admin/server/logs:/logs | ||||
|     depends_on: | ||||
|       - redis | ||||
|     privileged: true | ||||
|   nginx: | ||||
|     container_name: nginx | ||||
|     image: nginx:1.22.1 | ||||
|     restart: always | ||||
|     environment: | ||||
|       TZ: Asia/Shanghai | ||||
|     ports: | ||||
|       - '80:80' | ||||
|       - '443:443' | ||||
|     volumes: | ||||
|       - /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf | ||||
|       - /docker/nginx/logs:/var/log/nginx | ||||
|       - /docker/nginx/cert:/etc/nginx/cert | ||||
|     privileged: true | ||||
							
								
								
									
										64
									
								
								docker/nginx/conf/nginx.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								docker/nginx/conf/nginx.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| worker_processes  1; | ||||
|  | ||||
| error_log  /var/log/nginx/error.log warn; | ||||
| pid        /var/run/nginx.pid; | ||||
|  | ||||
| events { | ||||
|     worker_connections  1024; | ||||
| } | ||||
|  | ||||
| http { | ||||
|     include       mime.types; | ||||
|     default_type  application/octet-stream; | ||||
|     sendfile        on; | ||||
|     keepalive_timeout  65; | ||||
|     # 限制 body 大小 | ||||
|     client_max_body_size 100m; | ||||
|  | ||||
|     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; | ||||
|  | ||||
|     upstream admin-server { | ||||
|         ip_hash; | ||||
|         server 172.17.0.1:8000; | ||||
|     } | ||||
|  | ||||
|     server { | ||||
|         listen       80; | ||||
|         # listen       443 ssl; | ||||
|         server_name  cnadmin.charles7c.top; | ||||
|  | ||||
|         # 证书直接存放 /docker/nginx/cert 目录下即可(更改证书名称即可,无需更改证书路径) | ||||
|         # ssl on; | ||||
|         # ssl_certificate      /etc/nginx/cert/xxx.local.pem; # /etc/nginx/cert/ 为 docker 映射路径 不允许更改 | ||||
|         # ssl_certificate_key  /etc/nginx/cert/xxx.local.key; # /etc/nginx/cert/ 为 docker 映射路径 不允许更改 | ||||
|         # ssl_session_timeout 5m; | ||||
|         # ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; | ||||
|         # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | ||||
|         # ssl_prefer_server_ciphers on; | ||||
|  | ||||
|         location / { | ||||
|             proxy_set_header Host $http_host; | ||||
|             proxy_set_header X-Real-IP $remote_addr; | ||||
|             proxy_set_header REMOTE-HOST $remote_addr; | ||||
|             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||||
|             proxy_read_timeout 6000; | ||||
|             proxy_pass http://admin-server/; | ||||
|         } | ||||
|  | ||||
|         error_page   500 502 503 504  /50x.html; | ||||
|         location = /50x.html { | ||||
|             root   html; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     # HTTP 请求 将转发到 HTTPS | ||||
|     # server { | ||||
|     #     listen  80; | ||||
|     #     server_name  cnadmin.charles7c.top; | ||||
|     #     rewrite ^ https://$http_host$request_uri? permanent; | ||||
|     # } | ||||
| } | ||||
							
								
								
									
										29
									
								
								docker/redis/conf/redis.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								docker/redis/conf/redis.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| bind 0.0.0.0 | ||||
| # redis 密码 | ||||
| requirepass 123456 | ||||
|  | ||||
| # key 监听器配置 | ||||
| # notify-keyspace-events Ex | ||||
|  | ||||
| # 配置持久化文件存储路径 | ||||
| dir ../data | ||||
| # 配置rdb | ||||
| # 15分钟内有至少1个key被更改则进行快照 | ||||
| save 900 1 | ||||
| # 5分钟内有至少10个key被更改则进行快照 | ||||
| save 300 10 | ||||
| # 1分钟内有至少10000个key被更改则进行快照 | ||||
| save 60 10000 | ||||
| # 开启压缩 | ||||
| rdbcompression yes | ||||
| # rdb文件名 用默认的即可 | ||||
| dbfilename dump.rdb | ||||
|  | ||||
| # 开启aof | ||||
| appendonly yes | ||||
| # 文件名 | ||||
| appendfilename "appendonly.aof" | ||||
| # 持久化策略,no:不同步,everysec:每秒一次,always:总是同步,速度比较慢 | ||||
| # appendfsync always | ||||
| appendfsync everysec | ||||
| # appendfsync no | ||||
							
								
								
									
										1
									
								
								docker/redis/data/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								docker/redis/data/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| Redis 数据存储目录,请确保赋予了读写权限,否则将无法写入数据 | ||||
		Reference in New Issue
	
	Block a user