No more Dockerfile with Jib + Spring Boot plugin

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • НаукаНаука

Комментарии • 43

  • @TomGregoryTech
    @TomGregoryTech  2 года назад

    Thanks for watching! Would you use one of these tools in your project? Or is there something stopping you that I didn't consider? 🤔

    • @SirWolf2018
      @SirWolf2018 2 года назад

      I'd defo try it out when the opportunity comes...

  • @subhadipadhikary270
    @subhadipadhikary270 Год назад

    I have used jib and both multistage docker build and out of the box jib is not even close being as efficient as multistage docker build,maybe i did something wrong

  • @Prathyuprawin
    @Prathyuprawin 2 года назад +1

    Could you please help me for one task

  • @jovanthournout9707
    @jovanthournout9707 2 года назад +1

    Again, great content and value Tom

  • @SirWolf2018
    @SirWolf2018 2 года назад +1

    This is amazing, thanks for the info!

  • @spinacker16
    @spinacker16 2 года назад

    Ive got 401 unauthorized while I try to start jibDockerBuild. What kind of password it needs. I don't understand. I tried to use my docker account with Auth but it doesn't work

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Hi Ruslan. It sounds like it can't pull the base image. Presumably it can't authenticate with Docker Hub.
      I have 2 suggestions:
      1) run "docker login" command first docs.docker.com/engine/reference/commandline/login/
      2) add "to.auth" configuration based on github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#to-closure

  • @alexandermilosh7458
    @alexandermilosh7458 2 года назад

    Hi Tom, could you explain for newbie where is the place where
    username = property('myProperty')
    is placed.
    Thank you.

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      Hi Alexander. You can place a gradle.properties file in your user home directory ~/.gradle/gradle.properties with the key/value pair. Or use one of the other techniques highlighted in this video ruclips.net/video/BvXjlxJg2II/видео.html

  • @honestguy2161
    @honestguy2161 2 года назад

    Is it somehow possible to build images without having docker installed? I'd like to build docker image using jenkins pipeline without docker installed or any other plugins. Is it possible to build with maven or maven plugin without installing it.

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Hi. Yes, you can use Jib to build Java applications into a Docker image, without Docker installed. It has a Maven plugin too. Check it out and let me know how you get on github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin

  • @mehdimohammadi1623
    @mehdimohammadi1623 2 года назад

    How can I find out what are the other options which I have in bootBuildImage apart from `--publishImage`? Apology for asking as I do not know how to find details for a particular task in Gradle

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      Check out the docs under "Image customisations". There is a column called "Command-line option" there docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#build-image

  • @caffeinejavacode1475
    @caffeinejavacode1475 Год назад

    Hello
    if I want to bulid/push each module in a multimodule project, how conf would look like?

    • @TomGregoryTech
      @TomGregoryTech  Год назад

      Hi. Apply and configure the chosen plugin within each subproject's build script. Remove duplication by extracting common logic into a convention plugin.

  • @willemevenwel
    @willemevenwel 2 года назад

    Hey Tom, as always thanks for a great vid!
    Im wondering what the benefit woul be with regards to using jib over a ‘normal’ dockerfile? And if it worth it in the long run?

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      Hi Willem. Thank you. One advantage of jib is that you can use it in environments where the Docker daemon is not available. That could be very helpful for some CI environments. Check out the full feature list in the accompanying article tomgregory.com/jib-vs-spring-boot-for-building-docker-images

  • @guai9632
    @guai9632 2 года назад

    I noticed you have both jib and Palantir in your project. Why do you need both?

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      Hi guai. Sorry for the confusion. The com.palantir.docker plugin is not needed if you're using Jib.

  • @nehurane
    @nehurane 2 года назад

    Hello Tom, I did save my uname and pwd in gradle.properties (in plain english ATM) still I am getting with jib plugin > Build image failed, perhaps you should make sure your credentials. I did changes as said in Google docs for jib using docker-credential-osxkeychain in file .docker/config.json but no luck. Any clues?

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Hi Neha. What username and password are you referring to?

    • @nehurane
      @nehurane 2 года назад

      @@TomGregoryTech docket hub uname and pwd. I did saved in gradle.properties and did add auth in docker/config.json still it fails auth. I got two sets of auth one for workplace and one for private docker hub. That could be the issue?!?

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      @@nehurane Not too sure. Maybe check if you are able to pull images e.g. "docker pull openjdk:17"

  • @caffeinejavacode1475
    @caffeinejavacode1475 2 года назад

    Is there difference between Java and Kotlin gradle file?

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Yes, the syntax is different for applying the plugins and configuring them in Kotlin. These Spring Boot docs have some useful examples docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#build-image.examples.publish

    • @mehdimohammadi1623
      @mehdimohammadi1623 2 года назад

      @@TomGregoryTech something like this works for me in Kotlin DSL
      ```tasks.bootBuildImage{
      imageName=""
      isPublish=true
      tags=listOf("tag1","tag2")
      docker {
      publishRegistry{
      username=""
      password=""
      url=""
      }
      }```

  • @SB-gc8wf
    @SB-gc8wf 2 года назад

    Hi Tom, this is my very first YT comment in my life. Your content is absolutely fantastic! I really like to listen to your voice. Everything is clearly spoken, focused and to the point. Your topics are truly interesting even for me as an experienced java land resident. I am also a big fan of gradle and I still learn new things with your contributions. Keep up the good work! You really add value to the developer world.

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Hi S B. Thanks for sharing your first comment here! Your support is much appreciated. 👍

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Are there any other topics you're interested in a seasoned Java dev?

    • @mehdimohammadi1623
      @mehdimohammadi1623 2 года назад +1

      @@TomGregoryTech WebFlux topic wanted

  • @mehdimohammadi1623
    @mehdimohammadi1623 2 года назад

    Thank you very much, Tom, I am wondering is it possible to tag the images also? as pushing to the docker hub repository requires particular tagging for the image

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      Hi Mehdi. Good question!
      With the Jib Gradle plugin in build.gradle set "jib.to.tags". For the Spring Boot Gradle plugin it's "bootBuildImage.tags".
      Both of these take a list of tags.

    • @mehdimohammadi1623
      @mehdimohammadi1623 2 года назад

      @@TomGregoryTech I'm using Spring Boot 2.5.0, I can not see any tag attribute in this version

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      OK, I'm using Spring Boot plugin 2.6.1. You might need to update then. Here are the docs docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#build-image

  • @caffeinejavacode1475
    @caffeinejavacode1475 2 года назад

    I wanna create fat jar using Gradle and Kotlin for Spring Boot
    but inside my jar I see Spring files of boot library in root and my files in BOOT-INF instead in root
    I use id("org.springframework.boot")

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      Hi. That's the expected layout of the generated Spring Boot jar file. You should be able to execute the jar using a command like "java -jar build/libs/my-project.jar".

    • @caffeinejavacode1475
      @caffeinejavacode1475 2 года назад

      @@TomGregoryTech
      this is fat jar example
      ----- in root level spring classes
      ---- DEPENDENCY DIR
      ------ my project classes
      ------- other dependency
      I wanna on the root level my project classes that have access to its dependency
      I don't know why sping classes present on the root level

    • @TomGregoryTech
      @TomGregoryTech  2 года назад +1

      @@caffeinejavacode1475 org.springframework.boot.loader.Launcher is present at the root of the jar file because that's the main entrypoint, responsible for loading your application. BOOT-INF/classes is the standard location for your application classes. Any reason that doesn't work for you?
      Check out the docs which run through the Spring Boot jar file layout docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html

    • @caffeinejavacode1475
      @caffeinejavacode1475 2 года назад

      @@TomGregoryTech but what path will be to classes?
      as standard path com.proj ..... etc

    • @TomGregoryTech
      @TomGregoryTech  2 года назад

      It will be BOOT-INF/classes/com/proj/**