From 44dd9f83e9949617288f57997307d8e8cf2808e4 Mon Sep 17 00:00:00 2001 From: oddfar Date: Thu, 21 Dec 2023 23:00:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0Docker=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .run/campus-server.run.xml | 12 ++++++ campus-modular/Dockerfile | 20 +++++++++ doc/docker/docker-compose.yml | 72 +++++++++++++++++++++++++++++++ doc/docker/nginx/conf/nginx.conf | 49 +++++++++++++++++++++ doc/docker/redis/conf/redis.conf | 2 + doc/docker/redis/data/README.md | 1 + doc/docker/server/conf/README.md | 5 +++ {sql => doc/sql}/campus-1.1.2.sql | 0 vue_campus_admin/package.json | 2 +- 9 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 .run/campus-server.run.xml create mode 100644 campus-modular/Dockerfile create mode 100755 doc/docker/docker-compose.yml create mode 100644 doc/docker/nginx/conf/nginx.conf create mode 100644 doc/docker/redis/conf/redis.conf create mode 100644 doc/docker/redis/data/README.md create mode 100644 doc/docker/server/conf/README.md rename {sql => doc/sql}/campus-1.1.2.sql (100%) diff --git a/.run/campus-server.run.xml b/.run/campus-server.run.xml new file mode 100644 index 0000000..1caafd3 --- /dev/null +++ b/.run/campus-server.run.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/campus-modular/Dockerfile b/campus-modular/Dockerfile new file mode 100644 index 0000000..831f0fd --- /dev/null +++ b/campus-modular/Dockerfile @@ -0,0 +1,20 @@ +#FROM java:8 +FROM openjdk:8 + +MAINTAINER oddfar + +# 创建目录 +RUN mkdir -p /home/campus/conf + +WORKDIR /home/campus + +ENV SERVER_PORT=8160 + +EXPOSE ${SERVER_PORT} + +ADD ./target/campus-modular.jar ./app.jar + +ENTRYPOINT ["java", \ + "-Djava.security.egd=file:/dev/./urandom", \ + "-Dserver.port=${SERVER_PORT}", \ + "-jar", "app.jar"] diff --git a/doc/docker/docker-compose.yml b/doc/docker/docker-compose.yml new file mode 100755 index 0000000..7e1ba84 --- /dev/null +++ b/doc/docker/docker-compose.yml @@ -0,0 +1,72 @@ +version : '3' + +services: + mysql: + image: mysql:5.7 + container_name: mysql + environment: + # root 密码 + MYSQL_ROOT_PASSWORD: 123456789 + # 初始化数据库(后续的初始化sql会在这个库执行) + MYSQL_DATABASE: 'oddfar_campus' + volumes: + # 数据挂载 + - /docker/mysql/data/:/var/lib/mysql/ + # 配置挂载 + - /docker/mysql/conf/:/etc/mysql/conf.d/ + # 日志 + - /docker/mysql/logs:/logs + command: [ + 'mysqld', + '--innodb-buffer-pool-size=80M', + '--character-set-server=utf8mb4', + '--collation-server=utf8mb4_unicode_ci', + '--default-time-zone=+8:00', + '--lower-case-table-names=1' + ] + privileged: true + network_mode: "host" + + redis: + image: redis:6.2.12 + container_name: redis + volumes: + # 配置文件 + - /docker/redis/conf:/redis/config + # 数据文件 + - /docker/redis/data/:/redis/data/ + command: "redis-server /redis/config/redis.conf" + privileged: true + network_mode: "host" + + + nginx-web: + image: nginx:1.23.4 + container_name: nginx-web + environment: + # 时区上海 + TZ: Asia/Shanghai + volumes: + # 页面目录 + - /docker/nginx/html:/usr/share/nginx/html + # 证书映射 + - /docker/nginx/cert:/etc/nginx/cert + # 配置文件映射 + - /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf + # 日志目录 + - /docker/nginx/log:/var/log/nginx + privileged: true + network_mode: "host" + + campus-server: + image: campus/campus-server:1.1.8 + container_name: campus-server + environment: + # 时区上海 + TZ: Asia/Shanghai + SERVER_PORT: 8160 +# spring.config.additional-location: /home/campus/conf/application-prod.yml + volumes: + - /docker/server/conf:/home/campus/conf + privileged: true + network_mode: "host" diff --git a/doc/docker/nginx/conf/nginx.conf b/doc/docker/nginx/conf/nginx.conf new file mode 100644 index 0000000..0c4d550 --- /dev/null +++ b/doc/docker/nginx/conf/nginx.conf @@ -0,0 +1,49 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + # https配置参考 start + #listen 443 ssl; + + # 证书直接存放 /docker/nginx/cert/ 目录下即可 更改证书名称即可 无需更改证书路径 + #ssl on; + #ssl_certificate /etc/nginx/cert/xxx.local.crt; # /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; + # https配置参考 end + + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html; + index index.html index.htm; + } + + location /prod-api/{ + 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_pass http://127.0.0.1:8160/; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} \ No newline at end of file diff --git a/doc/docker/redis/conf/redis.conf b/doc/docker/redis/conf/redis.conf new file mode 100644 index 0000000..213e9ba --- /dev/null +++ b/doc/docker/redis/conf/redis.conf @@ -0,0 +1,2 @@ +# redis 密码 +# requirepass 123456 \ No newline at end of file diff --git a/doc/docker/redis/data/README.md b/doc/docker/redis/data/README.md new file mode 100644 index 0000000..fbc5474 --- /dev/null +++ b/doc/docker/redis/data/README.md @@ -0,0 +1 @@ +数据目录 请执行 `chmod 777 /docker/redis/data` 赋予读写权限 否则将无法写入数据 \ No newline at end of file diff --git a/doc/docker/server/conf/README.md b/doc/docker/server/conf/README.md new file mode 100644 index 0000000..c444413 --- /dev/null +++ b/doc/docker/server/conf/README.md @@ -0,0 +1,5 @@ +若您需要挂载使用外部配置文件 + +在 `/docker/server/conf` 创建 `application-prod.yml` 文件 + +并 `Environment` 加 `spring.config.additional-location: /home/campus/conf/application-prod.yml` diff --git a/sql/campus-1.1.2.sql b/doc/sql/campus-1.1.2.sql similarity index 100% rename from sql/campus-1.1.2.sql rename to doc/sql/campus-1.1.2.sql diff --git a/vue_campus_admin/package.json b/vue_campus_admin/package.json index 2ec3ced..f1e7e61 100644 --- a/vue_campus_admin/package.json +++ b/vue_campus_admin/package.json @@ -33,7 +33,7 @@ ], "repository": { "type": "git", - "url": "https://gitee.com/y_project/RuoYi-Vue.git" + "url": "https://gitee.com/oddfar/campus.git" }, "dependencies": { "@riophae/vue-treeselect": "0.4.0",