Skip to content

Commit

Permalink
feat: 增加Docker启动配置
Browse files Browse the repository at this point in the history
  • Loading branch information
oddfar committed Dec 21, 2023
1 parent 012d85a commit 44dd9f8
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .run/campus-server.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="campus-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="campus/campus-server:1.1.8" />
<option name="buildOnly" value="true" />
<option name="sourceFilePath" value="campus-modular/Dockerfile" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>
20 changes: 20 additions & 0 deletions campus-modular/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
72 changes: 72 additions & 0 deletions doc/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"
49 changes: 49 additions & 0 deletions doc/docker/nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
2 changes: 2 additions & 0 deletions doc/docker/redis/conf/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# redis 密码
# requirepass 123456
1 change: 1 addition & 0 deletions doc/docker/redis/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
数据目录 请执行 `chmod 777 /docker/redis/data` 赋予读写权限 否则将无法写入数据
5 changes: 5 additions & 0 deletions doc/docker/server/conf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
若您需要挂载使用外部配置文件

`/docker/server/conf` 创建 `application-prod.yml` 文件

`Environment``spring.config.additional-location: /home/campus/conf/application-prod.yml`
File renamed without changes.
2 changes: 1 addition & 1 deletion vue_campus_admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 44dd9f8

Please sign in to comment.