GithubHelp home page GithubHelp logo

gaohanghang / springboot-jib-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hacker-and-painter/springboot-jib-docker

0.0 0.0 0.0 7 KB

🏗 使用 Google jib 快速构建 springboot 项目镜像

Java 100.00%

springboot-jib-docker's Introduction

使用 Google jib 快速构建springboot项目镜像

google jib 是Google于18年7月发布的一个针对Java应用的构建镜像的工具(支持Maven和Gradle) ,好处是能够复用构建缓存,能够加快构建,减小传输体积(后文会详细讲解),并且让Java工程师不需要理解Docker相关知识就可以简单构建镜像并且发布到指定registry里(不需要docker build , tag, push)

项目地址: https://github.com/hacker-and-painter/springboot-jib-docker

先上运行效果

运行效果

docker pull gaohanghang/springboot-jib-docker

docker run -p 8080:8080 -t gaohanghang/springboot-jib-docker

快速开始

  1. dockerhub中创建Repository

  1. 创建springboot项目,添加HelloController.java
@RestController
public class HelloController {

    @GetMapping("/")
    public String hello() {
        return "hello";
    }
}
  1. pom.xml中添加jib plugin
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>1.3.0</version>
    <configuration>
        <from>
            <!--base image-->
            <image>openjdk:alpine</image>
        </from>
        <to>
            <!--<image>registry.cn-hangzhou.aliyuncs.com/m65536/jibtest</image>-->
            <!--目标镜像registry地址,为了方便测试,你需要换成自己的地址,如果你的网络不好,可以选用国内加速器,比如阿里云的-->
            <image>registry.hub.docker.com/gaohanghang/springboot-jib-docker</image>
        </to>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>build</goal>
            </goals>
        </execution>
    </executions>
</plugin>
  1. <image>registry.hub.docker.com/gaohanghang/springboot-jib-docker</image>中的gaohanghang/springboot-jib-docker修改为你在dockerhub中创建的Repository

  2. 使用maven package打包项目,jib会自动构建镜像到dockerhub

  1. 拉取镜像并运行
docker pull gaohanghang/springboot-jib-docker

docker run -p 8080:8080 -t gaohanghang/springboot-jib-docker

参考文章

Jib构建你的第一个java镜像 谷歌开源 Java 镜像构建工具 Jib 加速和简化构建Docker(基于Google jib)

springboot-jib-docker's People

Contributors

gaohanghang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.