美文网首页docker
jenkins自动部署脚本

jenkins自动部署脚本

作者: 胸口砕大石 | 来源:发表于2020-01-15 09:49 被阅读0次

    前台

    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" ]
    

    相关文章

      网友评论

        本文标题:jenkins自动部署脚本

        本文链接:https://www.haomeiwen.com/subject/wsvxactx.html