- 将打包好的jar包和Dockerfile复制到/root/app/qilaike-admin
cd /root/app/qilaike-admin
if [ x"$(docker ps -a | awk '($2 ~ /qilaike-admin:*/) {print $1}')" != x"" ];
then
docker rm -f $(docker ps -a | awk '($2 ~ /qilaike-admin:*/) {print $1}')
fi
if [ x"$(docker images | awk '($1 ~ /qilaike-admin:*/) {print $3}')" != x"" ];
then
docker rmi $(docker images | awk '($1 ~ /qilaike-admin:*/) {print $3}')
fi
docker build -t qilaike-admin:$BUILD_NUMBER .
docker run -p 8888:8080 --restart=always --name qilaike-admin \
-e TZ=Asia/Shanghai \
-e spring.profiles.active=druid \
-v /home/qilaike:/home/qilaike \
-d qilaike-admin:$BUILD_NUMBER
# 使用 openjdk:17 作为基础镜像
FROM openjdk:17
# 设置镜像的维护者信息
LABEL maintainer="YanLie"
# 将本地的 qilaike-admin.jar 文件复制到容器的 / 目录下,并重命名为 app.jar
COPY qilaike-admin/qilaike-admin.jar /app.jar
# 设置容器启动时执行的命令,运行 app.jar 中的 Java 应用程序
ENTRYPOINT ["/bin/sh","-c", "java -Dfile.encoding=UTF-8 -jar app.jar"]