🎉 init-基础配置文件
This commit is contained in:
parent
22a64d0b06
commit
9ce48c5b2c
|
@ -0,0 +1,37 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
logs/
|
||||
|
||||
application-prod.yml
|
||||
application-staging.yml
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
|
@ -0,0 +1,49 @@
|
|||
# 定义CI/CD流水线的阶段
|
||||
stages:
|
||||
- build # 第一阶段:构建应用程序
|
||||
- build-docker # 第二阶段:构建Docker镜像
|
||||
- deploy # 第三阶段:部署应用程序
|
||||
|
||||
# 定义全局变量
|
||||
variables:
|
||||
CONTAINER_NAME: "bunny-auth-server" # Docker容器名称
|
||||
DOCKER_TAG: "4.0.0" # Docker镜像标签版本
|
||||
|
||||
# 构建任务
|
||||
build-job:
|
||||
stage: build # 指定此任务属于build阶段
|
||||
script:
|
||||
# 打印编译开始信息
|
||||
- echo "Compiling the code..."
|
||||
# 使用Maven编译Java项目,跳过测试
|
||||
- mvn clean package -DskipTests
|
||||
# 打印编译完成信息
|
||||
- echo "Compile complete."
|
||||
# 从Docker Hub拉取OpenJDK基础镜像
|
||||
- docker pull openjdk:24-ea-17-jdk-oraclelinux9
|
||||
# 打印拉取完成信息
|
||||
- echo "docker pull complete."
|
||||
# 使用Dockerfile构建Docker镜像,并打上标签
|
||||
- docker build -f Dockerfile -t $CONTAINER_NAME:$DOCKER_TAG .
|
||||
# 打印构建成功信息
|
||||
- echo "Application successfully deployed."
|
||||
|
||||
# 部署任务
|
||||
deploy-job:
|
||||
stage: deploy # 指定此任务属于deploy阶段
|
||||
environment: production # 指定部署环境为production
|
||||
script:
|
||||
# 打印部署开始信息
|
||||
- echo "Deploying application..."
|
||||
# 停止正在运行的容器(如果存在),|| true确保命令失败不会中断脚本
|
||||
- docker stop $CONTAINER_NAME || true
|
||||
# 删除容器(如果存在)
|
||||
- docker rm $CONTAINER_NAME || true
|
||||
# 运行新的Docker容器
|
||||
# -d: 后台运行
|
||||
# -p: 端口映射(7070和8000)
|
||||
# --name: 容器名称
|
||||
# --restart always: 总是自动重启
|
||||
- docker run -d -p 7070:7070 -p 8000:8000 --name $CONTAINER_NAME --restart always $CONTAINER_NAME:$DOCKER_TAG
|
||||
# 打印部署成功信息
|
||||
- echo "Application successfully deployed."
|
|
@ -0,0 +1,37 @@
|
|||
FROM openjdk:24-ea-17-jdk-oraclelinux9
|
||||
LABEL maintainer="server"
|
||||
|
||||
#系统编码
|
||||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||
|
||||
# 设置时区,构建镜像时执行的命令
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
# 设定工作目录
|
||||
WORKDIR /home/server
|
||||
|
||||
# 复制jar包
|
||||
COPY target/*.jar /home/server/app.jar
|
||||
|
||||
# 程序内部挂在目录
|
||||
VOLUME /usr/bin/docker
|
||||
VOLUME ["/var/run/docker.sock"]
|
||||
VOLUME /etc/docker/daemon.json
|
||||
VOLUME ["/www/root/backup"]
|
||||
VOLUME ["/www/root/server"]
|
||||
|
||||
# 启动容器时的进程
|
||||
ENTRYPOINT ["java","-jar","/home/server/app.jar"]
|
||||
|
||||
#暴露 8000 端口
|
||||
EXPOSE 8000
|
||||
EXPOSE 7070
|
||||
|
||||
# 生产环境
|
||||
# mvn clean package -Pprod -DskipTests
|
||||
# mvn clean package -Pdev -DskipTests
|
||||
|
||||
# 测试环境
|
||||
# mvn clean package -Ptest -DskipTests
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2024 Bunny
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,68 @@
|
|||
name: auth-compose # 定义该配置的名称为 auth-dependence
|
||||
services: # 定义服务列表
|
||||
|
||||
# 安装MySQL
|
||||
mysql: # 定义 MySQL 服务
|
||||
container_name: mysql_master # 容器名称为 mysql_master
|
||||
image: mysql:8.0.33 # 使用 MySQL 8.0.33 版本的镜像
|
||||
ports:
|
||||
- "3306:3306" # 将宿主机的 3306 端口映射到容器的 3306 端口
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=123456 # 设置 MySQL 的 root 用户密码为 123456
|
||||
- TZ=Asia/Shanghai # 设置时区为亚洲/上海
|
||||
volumes:
|
||||
# - ~/docker/docker_data/mysql/mysql_master/etc/my.cnf:/etc/my.cnf # 如果需要创建配置文件
|
||||
- ~/docker/docker_data/mysql/mysql_master/etc/mysql:/etc/mysql/conf.d # 挂载 MySQL 配置文件目录
|
||||
- ~/docker/docker_data/mysql/mysql_master/data:/var/lib/mysql # 挂载 MySQL 数据目录
|
||||
- ~/docker/docker_data/mysql/mysql_master/backup:/backup # 挂载备份目录
|
||||
command:
|
||||
- "--log-bin=mysql-bin" # 启用二进制日志
|
||||
- "--server-id=1" # 设置服务器 ID 为 1
|
||||
- "--collation-server=utf8mb4_unicode_ci" # 设置默认的排序规则为 utf8mb4_unicode_ci
|
||||
- "--character-set-server=utf8mb4" # 设置默认的字符集为 utf8mb4
|
||||
- "--lower-case-table-names=1" # 设置表名存储为小写
|
||||
restart: always # 设置容器总是自动重启
|
||||
privileged: true # 赋予容器特权模式
|
||||
networks:
|
||||
- auth # 将 MySQL 服务加入到 auth 网络
|
||||
|
||||
# 安装Redis
|
||||
redis: # 定义 Redis 服务
|
||||
container_name: redis_master # 容器名称为 redis_master
|
||||
image: redis:7.0.10 # 使用 Redis 7.0.10 版本的镜像
|
||||
ports:
|
||||
- "6379:6379" # 将宿主机的 6379 端口映射到容器的 6379 端口
|
||||
volumes:
|
||||
# - ~/docker/docker_data/redis_master/redis.conf:/etc/redis/redis.conf # 需要创建配置文件
|
||||
- ~/docker/docker_data/redis_master:/etc/redis # 挂载 Redis 配置文件目录
|
||||
- ~/docker/docker_data/redis_master/data:/data # 挂载 Redis 数据目录
|
||||
command:
|
||||
- "--appendonly yes" # 启用 AOF 持久化
|
||||
- "--daemonize no" # 不以守护进程方式运行
|
||||
- "--requirepass 123456" # 设置 Redis 访问密码为 123456
|
||||
- "--tcp-keepalive 300" # 设置 TCP keepalive 时间为 300 秒
|
||||
restart: always # 设置容器总是自动重启
|
||||
networks:
|
||||
- auth # 将 MySQL 服务加入到 auth 网络
|
||||
|
||||
# 安装 Minio
|
||||
minio: # 定义 Minio 服务
|
||||
image: minio/minio # 使用 Minio 官方镜像
|
||||
container_name: minio_master # 容器名称为 minio_master
|
||||
ports:
|
||||
- "9000:9000" # 将宿主机的 9000 端口映射到容器的 9000 端口
|
||||
- "9090:9090" # 将宿主机的 9090 端口映射到容器的 9090 端口
|
||||
volumes:
|
||||
- ~/docker/docker_data/minio/data:/data # 挂载 Minio 数据目录
|
||||
environment:
|
||||
- MINIO_ROOT_USER=bunny # 设置 Minio 的 root 用户名为 bunny
|
||||
- MINIO_ROOT_PASSWORD=12345678 # 设置 Minio 的 root 用户密码为 123456
|
||||
command: "server /data --console-address :9090" # 启动 Minio 服务并指定控制台地址
|
||||
restart: always # 设置容器总是自动重启
|
||||
networks:
|
||||
- auth # 将 MySQL 服务加入到 auth 网络
|
||||
|
||||
networks: # 定义网络
|
||||
auth: # 定义名为 auth 的网络
|
||||
name: auth # 网络名称为 auth
|
||||
driver: bridge # 使用 bridge 驱动(默认)
|
|
@ -0,0 +1,194 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.3.13</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.auth</groupId>
|
||||
<artifactId>auth-server</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>auth-admin</name>
|
||||
<description>auth-admin</description>
|
||||
|
||||
<modules>
|
||||
<module>auth-common</module>
|
||||
<module>auth-module</module>
|
||||
<module>auth-services</module>
|
||||
<module>auth-services</module>
|
||||
<module>auth-dao</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
<junit.version>3.8.1</junit.version>
|
||||
<mybatis-plus.version>3.5.6</mybatis-plus.version>
|
||||
<mysql.version>9.2.0</mysql.version>
|
||||
<knife4j.version>4.5.0</knife4j.version>
|
||||
<fastjson2.version>2.0.47</fastjson2.version>
|
||||
<minio.version>8.5.17</minio.version>
|
||||
<lombok.version>1.18.32</lombok.version>
|
||||
<jwt.version>0.12.6</jwt.version>
|
||||
<easyexcel.version>4.0.2</easyexcel.version>
|
||||
<jodatime.version>2.10.1</jodatime.version>
|
||||
<aspectj>1.9.21</aspectj>
|
||||
<pagehelper.version>6.1.0</pagehelper.version>
|
||||
<velocity.version>2.2</velocity.version>
|
||||
<velocity-tools.version>3.1</velocity-tools.version>
|
||||
<HikariCP.version>6.2.1</HikariCP.version>
|
||||
<dynamic.datasource.version>4.3.1</dynamic.datasource.version>
|
||||
<jackson-dataType.version>2.19.0</jackson-dataType.version>
|
||||
<quartz-scheduler.version>2.3.2</quartz-scheduler.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- 单元测试 -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
<!-- velocity -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity.tools</groupId>
|
||||
<artifactId>velocity-tools-generic</artifactId>
|
||||
<version>${velocity-tools.version}</version>
|
||||
</dependency>
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<!-- mysql连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>${HikariCP.version}</version>
|
||||
</dependency>
|
||||
<!-- 多数据库源插件 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
|
||||
<version>${dynamic.datasource.version}</version>
|
||||
</dependency>
|
||||
<!-- knife 4 j-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
<!-- fastjson2 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>${fastjson2.version}</version>
|
||||
</dependency>
|
||||
<!-- minio -->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>${minio.version}</version>
|
||||
</dependency>
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.27</version>
|
||||
</dependency>
|
||||
<!--jjwt-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<!-- Excel表操作 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>${easyexcel.version}</version>
|
||||
</dependency>
|
||||
<!-- aspectj -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>${aspectj}</version>
|
||||
</dependency>
|
||||
<!-- aspectj -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>${aspectj}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime.version}</version>
|
||||
</dependency>
|
||||
<!-- fasterxml -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-dataType.version}</version>
|
||||
</dependency>
|
||||
<!-- quartz定时任务 -->
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>${quartz-scheduler.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<profiles>
|
||||
<!--dev环境-->
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<profiles.active>dev</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<!--test环境-->
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<properties>
|
||||
<profiles.active>test</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<!--prod环境-->
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<profiles.active>prod</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
Loading…
Reference in New Issue