Browse Source

feat: docker相关文件更新

TzuxinChen 3 months ago
parent
commit
d8e1994b8c

+ 9 - 0
.env.example

@@ -0,0 +1,9 @@
+DB_HOST=mysql
+DB_USERNAME=root
+DB_PASSWORD=123456
+DB_NAME=zyc_db
+DB_PORT=3306
+REDIS_HOST=redis
+REDIS_PORT=6379
+REDIS_PASSWORD=
+REDIS_DATABASE=0

+ 6 - 0
.gitignore

@@ -7,6 +7,7 @@
 
 target/
 !.mvn/wrapper/maven-wrapper.jar
+*.jar
 
 ######################################################################
 # IDE
@@ -45,3 +46,8 @@ nbdist/
 !*/build/*.java
 !*/build/*.html
 !*/build/*.xml
+
+# docker
+.env
+docker/mysql
+docker/landian

+ 6 - 0
docker/db/sys_data.sql

@@ -16,7 +16,13 @@
 
 SET NAMES utf8mb4;
 SET FOREIGN_KEY_CHECKS = 0;
+-- 创建数据库
+CREATE DATABASE IF NOT EXISTS zyc_db
+CHARACTER SET utf8mb4
+COLLATE utf8mb4_general_ci;
 
+-- 使用数据库
+USE zyc_db;
 -- ----------------------------
 -- Table structure for QRTZ_BLOB_TRIGGERS
 -- ----------------------------

+ 20 - 9
docker/docker-compose.yaml

@@ -1,6 +1,7 @@
 version : '3'
 services:
   mysql:
+#    platform: linux/x86_64
     container_name: mysql
     image: mysql:5.7
     build:
@@ -21,8 +22,8 @@ services:
           '--lower-case-table-names=1'
         ]
     environment:
-      MYSQL_DATABASE: landian
-      MYSQL_ROOT_PASSWORD: ld123456
+      MYSQL_DATABASE: ${DB_NAME}
+      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
 
   redis:
     image: redis:5.0
@@ -30,17 +31,27 @@ services:
       - "6379:6379"
     restart: always
 
-  landian-server:
-    container_name: landian-server
+  zyc-server:
+    container_name: zyc-server
     build:
       context: .
-      dockerfile: landian-dockerfile
+      dockerfile: zyc-dockerfile
     ports:
       - "80:80"
     volumes:
-      - ./landian/logs:/home/landian/logs
-      - ./landian/uploadPath:/home/landian/uploadPath
+      - ./zyc/logs:/home/zyc/logs
+      - ./zyc/uploadPath:/home/zyc/uploadPath
     depends_on:
-      - landian-mysql
+      - mysql
     links:
-      - landian-mysqlw
+      - mysql
+    environment:
+      DB_HOST: ${DB_HOST}
+      DB_USERNAME: ${DB_USERNAME}
+      DB_PASSWORD: ${DB_PASSWORD}
+      DB_NAME: ${DB_NAME}
+      DB_PORT: ${DB_PORT}
+      REDIS_HOST: ${REDIS_HOST}
+      REDIS_PORT: ${REDIS_PORT}
+      REDIS_PASSWORD: ${REDIS_PASSWORD}
+      REDIS_DATABASE: ${REDIS_DATABASE}

+ 1 - 1
docker/landian-dockerfile → docker/zyc-dockerfile

@@ -1,5 +1,5 @@
 # 基础镜像
-FROM java:8
+FROM openjdk:8
 # author
 MAINTAINER landian
 

+ 3 - 3
resource-admin/src/main/resources/application-druid.yml

@@ -6,9 +6,9 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                username: root
-                password: 123456
+                url: jdbc:mysql://${DB_HOST}:${DB_PORT}/landian?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                username: ${DB_USERNAME}
+                password: ${DB_PASSWORD}
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭

+ 8 - 4
resource-admin/src/main/resources/application.yml

@@ -47,6 +47,9 @@ user:
 
 # Spring配置
 spring:
+  # 载入.env
+  config:
+    import: optional:file:.env[.properties]
   # 资源信息
   messages:
     # 国际化资源文件路径
@@ -68,13 +71,13 @@ spring:
   # redis 配置
   redis:
     # 地址
-    host: localhost
+    host: ${REDIS_HOST}
     # 端口,默认为6379
-    port: 6379
+    port: ${REDIS_PORT}
     # 数据库索引
-    database: 0
+    database: ${REDIS_DATABASE}
     # 密码
-    password:
+    password: ${REDIS_PASSWORD}
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -88,6 +91,7 @@ spring:
         # #连接池最大阻塞等待时间(使用负值表示没有限制)
         max-wait: -1ms
 
+
 # token配置
 token:
   # 令牌自定义标识