1、Dockerfile文件
#基于centos7.9
FROM kgfcentos:v1.0
#开发人员
MAINTAINER kgf
#创建目录
RUN mkdir -p /opt/ormis/ormis-admin/pdf \
&& mkdir -p /opt/ormis/ormis-admin/config \
&& mkdir -p /opt/ormis/ormis-admin/logs \
&& mkdir -p /opt/ormis/ormis-admin/images \
&& mkdir -p /opt/ormis/ormis-admin/shell
#将相关的依赖文件全部移动到指定的目录下
COPY pdf \
/opt/ormis/ormis-admin/pdf/
COPY images \
/opt/ormis/ormis-admin/images/
COPY shell \
/opt/ormis/ormis-admin/shell/
#拷贝配置文件
COPY config \
/opt/ormis/ormis-admin/config/
#复制jar包以及相关配置文件
COPY ormis-admin-1.0-SNAPSHOT.jar /opt/ormis/ormis-admin/
#添加进入docker容器后的目录
WORKDIR /opt/ormis/ormis-admin
#配置项目端口
CMD ["--server.port=7001"]
#对外暴露的端口号
EXPOSE 7001
#修改文件的创建修改时间
RUN bash -c 'touch /opt/ormis/ormis-admin/ormis-admin-1.0-SNAPSHOT.jar'
#运行脚本,启动springboot项目
#ENTRYPOINT ["java","-jar","/opt/ormis/ormis-admin/ormis-admin-1.0-SNAPSHOT.jar","-Dspring.config.location=/opt/ormis/ormis-admin/config/bootstrap.properties,/opt/ormis/ormis-admin/config/application.yml --logging.config=/opt/ormis/ormis-admin/config/log4j2-dev.xml > /opt/ormis/ormis-admin/logs/ormis-admin.log 2>&1 &"]
#CMD java -jar /opt/ormis/ormis-admin/ormis-admin-1.0-SNAPSHOT.jar -Dspring.config.location=/opt/ormis/ormis-admin/config/bootstrap.properties,/opt/ormis/ormis-admin/config/application.yml --logging.config=/opt/ormis/ormis-admin/config/log4j2-dev.xml > /opt/ormis/ormis-admin/logs/ormis-admin.log 2>&1 &
CMD ["sh","/opt/ormis/ormis-admin/shell/ormisAdminRun.sh"]
2、ormisAdminRun.sh脚本
#!/bin/bash
# 启动nginx服务
cd /usr/local/nginx/sbin
./nginx
#启动项目
nohup java -jar /opt/ormis/ormis-admin/ormis-admin-1.0-SNAPSHOT.jar -Dspring.config.location=/opt/ormis/ormis-admin/config/bootstrap.properties,/opt/ormis/ormis-admin/config/application.yml --logging.config=/opt/ormis/ormis-admin/config/log4j2-dev.xml > /opt/ormis/ormis-admin/logs/ormis-admin.log 2>&1 &
while [[ true ]];do
sleep 1
done