docker配置文件更新

This commit is contained in:
kerwincui
2022-03-22 17:03:10 +08:00
parent 7a7e9827ca
commit 3253ef9ab4
9 changed files with 109 additions and 113 deletions

View File

@@ -1,25 +1,31 @@
FROM openjdk:8u322-jre-buster
FROM openjdk:8u322-jre-slim-buster
ENV VERSION 1.1
ENV AUTHOR kerwincui
ENV INFO wumei smart open source living iot platform
ENV SERVERS nginx:1.14.2, redis-server:5.0.14, emqx:4.0, openjdk:8u322-jre-slim-buster
# mysql环境变量
ENV DB_HOST localhost
ENV DB_NAME wumei
ENV DB_USER root
ENV DB_PASSWORD admin
# 安装工具和设置时区 apt install curl -y --no-install-recommends && \ apt-get install vim -y --no-install-recommends && \
RUN apt-get update && \
# 安装网络工具和设置时区
apt-get install wget -y --no-install-recommends && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#更换国内源
RUN wget http://qiniu.xiwen.online/Debian10.list && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
# 更换国内源
wget http://qiniu.xiwen.online/Debian10.list && \
mv Debian10.list /etc/apt/sources.list && \
apt update && apt upgrade -y
# 安装nginx和redis
RUN apt-get install nginx -y --no-install-recommends && \
apt-get install redis-server -y --no-install-recommends
# 安装 emqx
RUN apt update && apt install -y \
apt update && apt upgrade -y && \
# 安装压缩工具
apt install zip -y && \
# 安装nginx和redis
apt-get install nginx -y --no-install-recommends && \
apt-get install redis-server -y --no-install-recommends && \
# 安装 emqx
apt update && apt install -y \
apt-transport-https \
ca-certificates \
curl \
@@ -31,27 +37,25 @@ RUN apt update && apt install -y \
./bionic \
stable" && \
apt update && \
apt install emqx=4.0.0 -y --no-install-recommends
# 修改redis配置
RUN sed -i "s/# requirepass foobared/requirepass wumei/g" /etc/redis/redis.conf
apt install emqx=4.0.0 -y --no-install-recommends && \
# 修改redis配置
sed -i "s/# requirepass foobared/requirepass wumei-smart/g" /etc/redis/redis.conf && \
sed -i "s/bind 127.0.0.1/# bind 127.0.0.1/g" /etc/redis/redis.conf
# 复制emqx和Nginx的配置文件
COPY ./emqx4.0/emqx.conf /etc/emqx/emqx.conf
COPY ./emqx4.0/emqx_auth_http.conf /etc/emqx/plugins/emqx_auth_http.conf
COPY ./emqx4.0/emqx_web_hook.conf /etc/emqx/plugins/emqx_web_hook.conf
COPY ./emqx4.0/loaded_plugins /var/lib/emqx/loaded_plugins
COPY ./nginx.conf /etc/nginx/nginx.conf
# 挂载卷
VOLUME /var/wumei-smart
# 拷贝前后端压缩文件到容器,容器内解压后删除
COPY ./wumei-smart.tar /var/
RUN cd /var && tar -xvf wumei-smart.tar && rm wumei-smart.tar
# 启动脚本
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
# 拷贝前后端压缩文件到容器,容器内解压后删除
COPY ./wumei-smart.tar /var/
RUN cd /var && tar -xvf wumei-smart.tar && rm wumei-smart.tar
# 映射端口可选8081、8883、18083、8083
# 映射端口
EXPOSE 80 1883 8083

View File

@@ -19,66 +19,30 @@ docker push kerwinci/wumei-smart:1.0
# 容器运行
docker run \
--name wumei-smart \
--env DB_HOST=wumei.live:3306 \
--env DB_NAME=wumei-smart \
--env DB_USER=root \
--env DB_PASSWORD=wumei-smart \
--publish 80:80 \
--publish 18083:18083 \
--publish 1883:1883 \
--publish 3306:3306 \
--publish 6379:6379 \
--restart always \
--publish 8083:8083 \
--volume /var/wumei-smart/java/uploadPath:/var/wumei-smart/java/uploadPath \
--restart unless-stopped \
--detach \
kerwincui/wumei-smart:1.0
kerwincui/wumei-smart:1.1
docker run ^
--name wumei-smart ^
--publish 80:80 ^
--publish 18083:18083 ^
--publish 1883:1883 ^
--publish 3306:3306 ^
--publish 6379:6379 ^
--restart always ^
--detach ^
kerwincui/wumei-smart:1.0
--publish 18083:18083 \
--publish 8084:8084 \
--publish 8883:8883 \
--publish 8081:8081 \
--publish 6379:6379 \
--publish 8080:8080 \
--volume /var/wumei-smart/java/logs:/var/wumei-smart/java/logs \
--volume /var/wumei-smart/nginx/nginx.conf:/etc/nginx/nginx.conf \
--volume /var/wumei-smart/nginx/error.log:/var/log/nginx/error.log \
--volume /var/wumei-smart/redis/redis.conf:/etc/redis/redis.conf \
--volume /var/wumei-smart/redis/redis-server.log:/var/log/redis/redis-server.log \
--volume /var/wumei-smart/emqx/emqx.conf:/etc/emqx/emqx.conf \
--volume /var/wumei-smart/emqx/log:/var/log/emqx \
########################容器内处理##########################
# 配置redis
# vim /etc/redis/redis.conf 取消注释requirepass admin123注释 bind:127.0.0.1
# 配置docker-entrypoint.sh
# vim /docker-entrypoint.sh 启动mysql和java app
# 配置nginx
# vim /etc/nginx/nginx.confnginx服务配置
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /var/wumei-smart/vue;
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://localhost:8080/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

View File

@@ -2,12 +2,24 @@
# start service
startTime=$(date "+%Y-%m-%d %H:%M:%S")
echo $startTime : wumei-smart is starting...
echo $startTime : wumei-smart is starting, please waiting ...
# 提取jar包配置文件
cd /var/wumei-smart/java
unzip app.jar BOOT-INF/classes/application-druid.yml
# 修改mysql配置
sed -i "s/{DB_HOST}/$DB_HOST/g" BOOT-INF/classes/application-druid.yml
sed -i "s/{DB_NAME}/$DB_NAME/g" BOOT-INF/classes/application-druid.yml
sed -i "s/{DB_USER}/$DB_USER/g" BOOT-INF/classes/application-druid.yml
sed -i "s/{DB_PASSWORD}/$DB_PASSWORD/g" BOOT-INF/classes/application-druid.yml
# 配置文件写入jar包并删除提取的配置
zip app.jar BOOT-INF/classes/application-druid.yml
rm -rf BOOT-INF
service nginx start
service redis-server start
emqx start
#java -jar /var/wumei-smart/java/app.jar
java -jar /var/wumei-smart/java/app.jar
while true

View File

@@ -127,18 +127,18 @@ cluster.autoclean = 5m
## Path to a file containing the client's private PEM-encoded key.
##
## Value: File
## cluster.etcd.ssl.keyfile = etc/certs/client-key.pem
## cluster.etcd.ssl.keyfile = /etc/emqx/certs/client-key.pem
## The path to a file containing the client's certificate.
##
## Value: File
## cluster.etcd.ssl.certfile = etc/certs/client.pem
## cluster.etcd.ssl.certfile = /etc/emqx/certs/client.pem
## Path to the file containing PEM-encoded CA certificates. The CA certificates
## are used during server authentication and when building the client certificate chain.
##
## Value: File
## cluster.etcd.ssl.cacertfile = etc/certs/ca.pem
## cluster.etcd.ssl.cacertfile = /etc/emqx/certs/ca.pem
##--------------------------------------------------------------------
## Cluster using Kubernates
@@ -194,7 +194,7 @@ node.cookie = emqxsecretcookie
## Data dir for the node
##
## Value: Folder
node.data_dir = data
node.data_dir = /var/lib/emqx
## Heartbeat monitoring of an Erlang runtime system. Comment the line to disable
## heartbeat, or set the value as 'on'
@@ -259,14 +259,14 @@ node.fullsweep_after = 1000
## Crash dump log file.
##
## Value: Log file
node.crash_dump = log/crash.dump
node.crash_dump = /var/log/emqx/crash.dump
## Specify SSL Options in the file if using SSL for Erlang Distribution.
##
## Value: File
##
## vm.args: -ssl_dist_optfile <File>
## node.ssl_dist_optfile = etc/ssl_dist.conf
## node.ssl_dist_optfile = /etc/emqx/ssl_dist.conf
## Sets the net_kernel tick time. TickTime is specified in seconds.
## Notice that all communicating nodes are to have the same TickTime
@@ -397,7 +397,7 @@ log.level = warning
## The dir for log files.
##
## Value: Folder
log.dir = log
log.dir = /var/log/emqx
## The log filename for logs of level specified in "log.level".
##
@@ -454,7 +454,7 @@ acl_nomatch = allow
## Default ACL File.
##
## Value: File Name
acl_file = etc/acl.conf
acl_file = /etc/emqx/acl.conf
## Whether to enable ACL cache.
##
@@ -1167,20 +1167,20 @@ listener.ssl.external.handshake_timeout = 15s
## See: http://erlang.org/doc/man/ssl.html
##
## Value: File
listener.ssl.external.keyfile = etc/certs/key.pem
listener.ssl.external.keyfile = /etc/emqx/certs/key.pem
## Path to a file containing the user certificate.
##
## See: http://erlang.org/doc/man/ssl.html
##
## Value: File
listener.ssl.external.certfile = etc/certs/cert.pem
listener.ssl.external.certfile = /etc/emqx/certs/cert.pem
## Path to the file containing PEM-encoded CA certificates. The CA certificates
## are used during server authentication and when building the client certificate chain.
##
## Value: File
## listener.ssl.external.cacertfile = etc/certs/cacert.pem
## listener.ssl.external.cacertfile = /etc/emqx/certs/cacert.pem
## The Ephemeral Diffie-Helman key exchange is a very effective way of
## ensuring Forward Secrecy by exchanging a set of keys that never hit
@@ -1197,7 +1197,7 @@ listener.ssl.external.certfile = etc/certs/cert.pem
## openssl dhparam -out dh-params.pem 2048
##
## Value: File
## listener.ssl.external.dhfile = etc/certs/dh-params.pem
## listener.ssl.external.dhfile = /etc/emqx/certs/dh-params.pem
## A server only does x509-path validation in mode verify_peer,
## as it then sends a certificate request to the client (this
@@ -1640,26 +1640,26 @@ listener.wss.external.verify_protocol_header = on
## See: listener.ssl.$name.keyfile
##
## Value: File
listener.wss.external.keyfile = etc/certs/key.pem
listener.wss.external.keyfile = /etc/emqx/certs/key.pem
## Path to a file containing the user certificate.
##
## See: listener.ssl.$name.certfile
##
## Value: File
listener.wss.external.certfile = etc/certs/cert.pem
listener.wss.external.certfile = /etc/emqx/certs/cert.pem
## Path to the file containing PEM-encoded CA certificates.
##
## See: listener.ssl.$name.cacert
##
## Value: File
## listener.wss.external.cacertfile = etc/certs/cacert.pem
## listener.wss.external.cacertfile = /etc/emqx/certs/cacert.pem
## See: listener.ssl.$name.dhfile
##
## Value: File
## listener.ssl.external.dhfile = etc/certs/dh-params.pem
## listener.ssl.external.dhfile = /etc/emqx/certs/dh-params.pem
## See: listener.ssl.$name.vefify
##
@@ -1871,15 +1871,15 @@ module.rewrite = off
## The etc dir for plugins' config.
##
## Value: Folder
plugins.etc_dir = etc/plugins/
plugins.etc_dir = /etc/emqx/plugins/
## The file to store loaded plugin names.
##
## Value: File
plugins.loaded_file = data/loaded_plugins
plugins.loaded_file = /var/lib/emqx/loaded_plugins
## File to store loaded plugin names.
plugins.expand_plugins_dir = plugins/
plugins.expand_plugins_dir = /var/lib/emqx/plugins/
##--------------------------------------------------------------------
## Broker

View File

@@ -10,17 +10,17 @@
## are used during server authentication and when building the client certificate chain.
##
## Value: File
## auth.http.ssl.cacertfile = etc/certs/ca.pem
## auth.http.ssl.cacertfile = /etc/emqx/certs/ca.pem
## The path to a file containing the client's certificate.
##
## Value: File
## auth.http.ssl.certfile = etc/certs/client-cert.pem
## auth.http.ssl.certfile = /etc/emqx/certs/client-cert.pem
## Path to a file containing the client's private PEM-encoded key.
##
## Value: File
## auth.http.ssl.keyfile = etc/certs/client-key.pem
## auth.http.ssl.keyfile = /etc/emqx/certs/client-key.pem
##--------------------------------------------------------------------
## HTTP Request Headers

View File

@@ -0,0 +1,8 @@
{emqx_management,true}.
{emqx_recon,true}.
{emqx_retainer,true}.
{emqx_dashboard,true}.
{emqx_rule_engine,true}.
{emqx_bridge_mqtt,false}.
{emqx_auth_http,true}.
{emqx_web_hook,true}.

View File

@@ -26,7 +26,7 @@ http {
charset utf-8;
location / {
root /var/data/wumei/vue;
root /var/wumei-smart/vue;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
@@ -39,6 +39,14 @@ http {
proxy_pass http://localhost:8080/;
}
location /api/v4/ {
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://localhost:8081/api/v4/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;