一、环境描述
- CPU:双核
- 内存:4 GB
- 硬盘:120 GB
- IP地址:192.168.190.128
- 操作系统:CentOS 7.4 x86_64 Minimal
二、安装依赖包
1. 添加epel源
在shell中运行以下命令:
yum install -y epel-release
2. 安装OpenJDK
在shell中运行以下命令:
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
sed -i '$a\export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64' /etc/profile
source /etc/profile
3. 安装Git
在shell中运行以下命令:
yum install -y git
4. 安装Maven
在shell中运行以下命令:
yum install -y wget
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
5. 克隆Disconf代码库
在shell中运行以下命令:
cd /root/Downloads
git clone https://github.com/knightliao/disconf.git
三、克隆和打包
1. 复制和打包配置文件
在shell中运行以下命令:
mkdir -p /root/Downloads/disconf-build/{resources,war}
cp /root/Downloads/disconf/disconf-web/profile/rd/* /root/Downloads/disconf-build/resources/
cd /root/Downloads/disconf-build/resources/
mv application-demo.properties application.properties
cd /root/Downloads/disconf-build
tar cvzf resources.tar.gz resources
2. 构建WAR包
在shell中运行以下命令:
export ONLINE_CONFIG_PATH=/root/Downloads/disconf-build/resources
export WAR_ROOT_PATH=/root/Downloads/disconf-build/war
cd /root/Downloads/disconf/disconf-web/
sh deploy/deploy.sh
rm -rf /root/Downloads/disconf-build/resources
3. 分卷压缩
构建得到的WAR文件体积较大,不能直接上传至GitHub,需要进行分卷压缩分割成多个文件,在shell中运行以下命令:
mv /root/Downloads/disconf-build/war/disconf-web.war /root/Downloads/disconf-build/
rm -rf /root/Downloads/disconf-build/war
cd /root/Downloads/disconf-build/
tar -czvf - disconf-web.war | split -b 10m -d - disconf-web.tar.gz
rm -rf /root/Downloads/disconf-build/disconf-web.war
4. 复制和打包SQL文件
在shell中运行以下命令:
cp -r /root/Downloads/disconf/disconf-web/sql /root/Downloads/disconf-build/sql
cd /root/Downloads/disconf-build
tar cvzf sql.tar.gz sql
rm -rf /root/Downloads/disconf-build/sql
5. 复制和打包静态资源
在shell中运行以下命令:
cp -r /root/Downloads/disconf/disconf-web/html /root/Downloads/disconf-build/disconf-static
cd /root/Downloads/disconf-build
tar cvzf disconf-static.tar.gz disconf-static
rm -rf /root/Downloads/disconf-build/disconf-static
四、上传至GitHub
将编译和打包得到的静态资源、WAR包、SQL和配置文件,上传至自己的GitHub,如下图所示:
其中:
-
disconf-static.tar.gz
Disconf的前端静态资源压缩包。 -
disconf-web.tar.gz00 ~ disconf-web.tar.gz03
Disconf后端服务的分卷压缩包。 -
resources.tar.gz
Disconf配置文件压缩包。 -
sql.tar.gz
Disconf数据库的初始化脚本压缩包。
接下来,就可以制作Disconf的前端和后端的Docker镜像了!