前台
appName="storeroom_web"
port="10010"
if [ "$(cat version)" != "$(sudo docker service inspect --format='{{.Spec.TaskTemplate.ContainerSpec.Image}}' ${appName}|egrep -Eo '([^:|^@]*)@'|grep -Eo '([^:|^@]*)')" ] ;then
sudo docker build -t 192.168.7.80/${appName}/${appName}:$(cat version) .
sudo docker push 192.168.7.80/${appName}/${appName}:$(cat version)
sudo docker service create --name ${appName} --publish ${port}:80 --replicas=1 192.168.7.80/${appName}/${appName}:$(cat version)
#sudo docker service update --image 192.168.7.80/${appName}/${appName}:$(cat version) ${appName}
fi
前台 Dockerfile
FROM nginx
COPY ./ /usr/share/nginx/html/
后台
appName="packagecenter"
port="10008"
if [ "$(cat version)" != "$(sudo docker service inspect --format='{{.Spec.TaskTemplate.ContainerSpec.Image}}' ${appName}|egrep -Eo '([^:|^@]*)@'|grep -Eo '([^:|^@]*)')" ] ;then
#mvn deploy
mvn clean install -DskipTests
sudo docker build -t 192.168.7.80/${appName}/${appName}:$(cat version) .
sudo docker push 192.168.7.80/${appName}/${appName}:$(cat version)
#sudo docker service create --name ${appName} --publish ${port}:8091 --replicas=1 192.168.7.80/${appName}/${appName}:$(cat version)
sudo docker service update --image 192.168.7.80/${appName}/${appName}:$(cat version) ${appName}
fi
后台 Dockerfile
FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD target/*.jar app.jar
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
网友评论