Browse Source

fix: 🐛 websocket代理、优先使用镜像而不是重新编译、端口修改、容器名称修改

master
愿您有个好心情 2 years ago
parent
commit
10b8e75263
  1. 3
      .dockerignore
  2. 7
      .gitignore
  3. 8
      docker-compose.yml
  4. 4
      service/Dockerfile
  5. 6
      service/config/application-prod.yml
  6. 5
      web/Dockerfile
  7. 58
      web/conf.d/default.conf

3
.dockerignore

@ -21,8 +21,5 @@
**/obj **/obj
**/secrets.dev.yaml **/secrets.dev.yaml
**/values.dev.yaml **/values.dev.yaml
**/*.jar
service/opt/
web/html/
LICENSE LICENSE
README.md README.md

7
.gitignore

@ -1,3 +1,4 @@
**/*.jar service/*.jar
service/opt/ service/data/
web/html/ web/html/
images

8
docker-compose.yml

@ -2,11 +2,15 @@ version: '2'
services: services:
military-system: military-system:
build: service build: service
image: military_system
container_name: military_system
restart: on-failure restart: on-failure
ports: ports:
- 8080:8080 - 8049:8049
military-web: military-web:
build: web build: web
image: military_system_web
container_name: military_system_web
restart: on-failure restart: on-failure
ports: ports:
- 8089:8089 - 3001:3001

4
service/Dockerfile

@ -6,6 +6,9 @@
# 基础镜像 # 基础镜像
FROM openjdk:8-jdk-alpine FROM openjdk:8-jdk-alpine
LABEL Author="bb, aagmix"
LABEL VERSION="1.0"
VOLUME [ "/data" ] VOLUME [ "/data" ]
ARG JAVA_OPTS ARG JAVA_OPTS
@ -15,6 +18,7 @@ ENV JAVA_OPTS=$JAVA_OPTS
# 从当前工作目录复制文件到镜像目录中并重新命名 # 从当前工作目录复制文件到镜像目录中并重新命名
COPY config /military/config COPY config /military/config
COPY data /data
COPY military.jar /military/military.jar COPY military.jar /military/military.jar
# 执行Linux命令,运行jar包 # 执行Linux命令,运行jar包

6
service/config/application-prod.yml

@ -1,5 +1,5 @@
server: server:
port: 8080 port: 8049
tomcat: tomcat:
max-swallow-size: -1 max-swallow-size: -1
error: error:
@ -187,9 +187,9 @@ jeecg:
uploadType: local uploadType: local
path: path:
#文件上传根目录 设置 #文件上传根目录 设置
upload: /opt/upFiles upload: /data/upFiles
#webapp文件路径 #webapp文件路径
webapp: /opt/webapp webapp: /data/webapp
shiro: shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/** excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
#阿里云oss存储和大鱼短信秘钥配置 #阿里云oss存储和大鱼短信秘钥配置

5
web/Dockerfile

@ -6,6 +6,9 @@
# 基础镜像 # 基础镜像
FROM nginx FROM nginx
LABEL Author="bb, aagmix"
LABEL VERSION="1.0"
# config # config
COPY nginx.conf /etc/nginx COPY nginx.conf /etc/nginx
COPY conf.d /etc/nginx/conf.d COPY conf.d /etc/nginx/conf.d
@ -13,6 +16,6 @@ COPY conf.d /etc/nginx/conf.d
COPY html /usr/share/nginx/html COPY html /usr/share/nginx/html
# 暴露端口 # 暴露端口
EXPOSE 8089 EXPOSE 3001
CMD "nginx" "-g" "daemon off;" CMD "nginx" "-g" "daemon off;"

58
web/conf.d/default.conf

@ -1,21 +1,45 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream back_end {
server military-system:8049; # appserver_ip:ws_port
}
server { server {
listen 8089; listen 3001;
listen [::]:8089; listen [::]:3001;
server_name localhost; server_name localhost;
# 后台服务配置,配置了这个location便可以通过访问 # 后台服务配置,配置了这个location便可以通过访问
location ^~ /military { location ^~ /military {
proxy_pass http://military-system:8080/military/; proxy_pass http://back_end/military/;
proxy_set_header Host $host:8089; proxy_set_header Host $host:3001;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} location ^~ /military/websocket {
#解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 proxy_pass http://back_end/military/websocket/;
location / { proxy_read_timeout 300s;
root /usr/share/nginx/html; proxy_send_timeout 300s;
index index.html index.htm;
if (!-e $request_filename) { proxy_set_header Host $host:3001;
rewrite ^(.*)$ /index.html?s=$1 last; proxy_set_header X-Real-IP $remote_addr;
break; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
} proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
#解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题
location / {
root /usr/share/nginx/html;
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html?s=$1 last;
break;
}
}
} }
Loading…
Cancel
Save