• 【docker】将Java jar文件生成镜像、上传镜像并生成镜像压缩文件


    概述

    将Springboot的web服务打包成Jar包后,自动化脚本将jar打包成镜像、上传镜像、并生成镜像的压缩文件;

    Dockerfile

    FROM 10.254.9.21/library/oraclejdk:0.0.1
    ENV TZ=Asia/Shanghai
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    ADD epic-tako.jar epic-tako.jar
    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/epic-tako.jar"]
    
    

    配置文件

    pack.conf

    version=0.1.34.report.RL
    serviceName=epic-tako
    targetTagName=10.254.9.21/library/$serviceName:$version
    imagePath=/opt/install/images
    

    脚本

    1. 根据Dockerfile文件build出镜像
    2. push镜像到仓库;
    3. 将镜像save为tar.gz文件
    #!/bin/sh
    source ./pack.conf
    
    echo "begin to build image"
    echo "[exec]: docker build -t $targetTagName -f Dockerfile ."
    docker build -t $targetTagName -f Dockerfile .
    
    echo "[exec]: docker push $targetTagName"
    docker push $targetTagName
    
    mkdir $imagePath
    echo "[exec]: docker save $targetTagName | gzip > $imagePath/$serviceName.$version.tar.gz"
    docker save $targetTagName | gzip > $imagePath/$serviceName.$version.tar.gz
    ls -lh $imagePath | grep $serviceName.$version.tar.gz
    
    
  • 相关阅读:
    Hash详解
    手写2048
    20180429模拟赛T1——添边问题
    题解:UVA1025 A Spy in the Metro
    20180418模拟赛T2——Gym
    20180418模拟赛T1——Seq
    学习:中国剩余定理
    20180414模拟赛T2——拼图
    20180414模拟赛T1——BEAD
    学习:树状数组
  • 原文地址:https://www.cnblogs.com/ssslinppp/p/8573417.html
Copyright © 2020-2023  润新知