java~springboot~gradle里的docker集成

栏目: Java · 发布时间: 7年前

内容简介:在springboot里,我们的task任务可以添加docker构建的功能,在gradle集成环境里,直接可以实现编译,测试,打包镜像的流水线作业,很是方便!下面分享给大家,在gradle里添加docker镜像的构建功能。

在springboot里,我们的task任务可以添加 docker 构建的功能,在gradle集成环境里,直接可以实现编译,测试,打包镜像的流水线作业,很是方便!

下面分享给大家,在gradle里添加docker镜像的构建功能。

添加依赖

apply plugin: 'docker'

buildscript {
  repositories {
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath('se.transmode.gradle:gradle-docker:1.2')
    }

  } 
}

添加Dockerfile

//建立目录:/src/main/docker/
FROM fabric8/java-jboss-openjdk8-jdk:1.4

ENV JAVA_APP_JAR="app.jar"
ENV JAVA_MAX_MEM_RATIO=100
ENV AB_OFF ""
ADD --chown=jboss:jboss lindone-0.0.1.jar /deployments/app.jar

添加部署脚本

// 打包镜像
task buildDocker(type: Docker, dependsOn: build) {
    push = false
    applicationName = jar.baseName
    dockerfile = file('src/main/docker/Dockerfile')
    doFirst {
        copy {
            from jar
            into stageDir
        }
    }
}
// 复制jar文件
task copyJar(type: Copy) {
    dependsOn 'jar'
    from "build/libs/lindone-0.0.1.jar"
    into 'build/docker'
}
buildDocker.dependsOn copyJar

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

A Guide to Monte Carlo Simulations in Statistical Physics

A Guide to Monte Carlo Simulations in Statistical Physics

Landau, David P./ Binder, Kurt / Cambridge Univ Pr / 2005-9 / 786.00元

This new and updated edition deals with all aspects of Monte Carlo simulation of complex physical systems encountered in condensed-matter physics, statistical mechanics, and related fields. After brie......一起来看看 《A Guide to Monte Carlo Simulations in Statistical Physics》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试