Docker部署rocketmq-dashboard-1.0.0

一. 下载安装包并解压
# 如果使用官方镜像请移步,这里的步骤主要针对的是下载源码自定义配置制作镜像
# 也可将源码下载到本地后修改配置然后用IDE工具编译打包成jar包
# 请确保当前服务器已安装和配置Docker环境,安装JDK和Maven
# 下载源码,github下载源码可能会失败,可重试几次
wget https://github.com/apache/rocketmq-dashboard/archive/refs/tags/rocketmq-dashboard-1.0.0.tar.gz
# 创建文件夹并将安装包移动至目录
mkdir -p /opt/docker-rocketmq-dashboard
# 解压文件至上一步创建目录
tar -zxvf rocketmq-dashboard-1.0.0.tar.gz -C /opt/docker-rocketmq-dashboard/
cd /opt/docker-rocketmq-dashboard/rocketmq-dashboard-rocketmq-dashboard-1.0.0 && mv rocketmq-dashboard-rocketmq-dashboard-1.0.0 rocketmq-dashboard-1.0.0
二. 修改rocketmq-dashboard配置,并编译打包
# 1.修改application.properties
cd /opt/docker-rocketmq-dashboard/rocketmq-dashboard-1.0.0/src/main/resources && vim application.properties
# 修改内容如下
# 添加RocketMQ NameServer地址
rocketmq.config.namesrvAddr=192.168.128.10:9876
# 关闭VIPChannel
rocketmq.config.isVIPChannel=false
# 设置数据存储路径
rocketmq.config.dataPath=/opt/rocketmq-dashboard/data
# 设置访问需登陆
rocketmq.config.loginRequired=true

# 2.修改logback.xml
# 将日志路径修改为自定义路径
<file>${user.home}/logs/consolelogs/rocketmq-console.log</file>
改为
<file>/opt/rocketmq-dashboard/logs/rocketmq-console.log</file>

<fileNamePattern>${user.home}/logs/consolelogs/rocketmq-console-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
改为
<fileNamePattern>/opt/rocketmq-dashboard/logs/rocketmq-console-%d{yyyy-MM-dd}.%i.log</fileNamePattern>

# 3.编译打包
cd /opt/docker-rocketmq-dashboard/rocketmq-dashboard-1.0.0
mvn clean package -Dmaven.test.skip=true
mv /opt/docker-rocketmq-dashboard/rocketmq-dashboard-1.0.0/target/rocketmq-dashboard-1.0.0.jar /opt/docker-rocketmq-dashboard/rocketmq-dashboard-1.0.0.jar
cp /opt/docker-rocketmq-dashboard/rocketmq-dashboard-1.0.0/src/resources/role-permission.yml /opt/docker-rocketmq-dashboard/role-permission.yml
cp /opt/docker-rocketmq-dashboard/rocketmq-dashboard-1.0.0/src/resources/users.properties /opt/docker-rocketmq-dashboard/users.properties
三. 创建数据和日志目录
# 创建数据和日志目录
mkdir -p /opt/rocketmq-dashboard/data
mkdir -p /opt/rocketmq-dashboard/logs
四. 编写Dockerfile文件并构建镜像
# 编写dockerfile文件
cd /opt/docker-rocketmq-dashboard && vim Dockerfile

# Dockerfile内容如下
FROM openjdk:8-jdk
LABEL maintainer=frank
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN mkdir -p /opt/rocketmq-dashboard/data
RUN mkdir -p /opt/rocketmq-dashboard/logs
COPY rocketmq-dashboard-1.0.0.jar /opt/
COPY users.properties /opt/rocketmq-dashboard/data/
COPY role-permission.yml /opt/rocketmq-dashboard/data/
VOLUME ["/opt/rocketmq-dashboard/logs", "/opt/rocketmq-dashboard/data"]
EXPOSE 8080
CMD java -jar /opt/rocketmq-dashboard-1.0.0.jar

# 构建镜像
cd /opt/docker-rocketmq-dashboard && docker build -f Dockerfile -t rocketmq-dashboard:1.0.0 .
五. 启动容器访问页面
# 启动容器
docker run -d -p 10080:8080 --name rocketmq-dashboard-1.0.0 -v /opt/rocketmq-dashboard/data:/opt/rocketmq-dashboard/data -v /opt/rocketmq-dashboard/logs:/opt/rocketmq-dashboard/logs rocketmq-dashboard:1.0.0

# 通过浏览器访问dashboard
http://192.168.128.10:10080
账号:admin/admin

你可能感兴趣的:(linux,centos,java,中间件)