dockerfile内容:
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER lw
# 挂载目录
VOLUME /home/ybss
# 创建目录
RUN mkdir -p /home/ybss
# 指定路径
WORKDIR /home/ybss
ADD ./jar/lib /home/ybss/lib
ADD ./jar/*.yml /home/ybss/
# 复制jar文件到路径
COPY ./jar/run.jar /home/ybss/run.jar
# 启动认证服务
ENTRYPOINT ["java","-jar","-Dserver.port=9200","-Dspring.profiles.active=dev","run.jar"]
docker-compose.yml 内容:
version : '3.8'
services:
ybss-auth:
container_name: ybss-auth
build:
context: ./ybss/auth
dockerfile: dockerfile
ports:
- "19200:9200"
volumes:
- /home/ybss/ybss/auth/jar:/home/ybss
networks:
ybss_default:
driver: bridge
volumes挂载目录/home/ybss/ybss/auth/jar,有更新时,只需要把更新jar和文件替换即可。
部署脚本shell:
#!/bin/sh
auth(){
chmod 777 -R ./ybss/auth/*
docker-compose up -d ybss-auth
}
stop(){
docker-compose stop
}
case "$1" in
"auth")
auth
;;
"s")
stop
;;