美文网首页Docker容器
用docker安装的Jenkins构建SpringBoot的do

用docker安装的Jenkins构建SpringBoot的do

作者: yellow_han | 来源:发表于2018-08-21 16:58 被阅读0次

    1、在目录下创建Dockerfile

    image.png

    2、Dockerfile文件内容:

    FROM java:8
    MAINTAINER 457030599@qq.com
    VOLUME /tmp
    ARG JAR_FILE
    COPY guns-rest-0.0.1.jar app.jar
    RUN bash -c 'touch /app.jar'
    EXPOSE 80
    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","-Denv=DEV","/app.jar"]
    

    3、远程登陆服务器,执行脚本

    a、首先在系统设置里面一个远程host


    image.png

    b、在配置里的Post Step选Execute shell script on remote host using ssh


    image.png

    4、详细脚本内容

    docker stop guns-rest #停掉容器
    docker rm guns-rest #删除容器
    \cp /opt/data/jenkins/workspace/my-wechat/guns-rest/target/guns-rest-0.0.1.jar /opt/data/jenkins/workspace/my-wechat/docker/guns-rest-0.0.1.jar #jar包复制到dockerfile相同目录下
    cd /opt/data/jenkins/workspace/my-wechat/guns-rest/docker
    docker build -t hsshy/guns-rest . #构建镜像
    docker run --name guns-rest -p 80:80 -d hsshy/guns-rest #运行容器
    

    相关文章

      网友评论

        本文标题:用docker安装的Jenkins构建SpringBoot的do

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