#Hello, I've been looking into using

1 messages ยท Page 1 of 1 (latest)

wispy nacelle
#

Welcome @vivid rain ! Taking a quick look, it should be easy to run JIB builds in a container in Dagger.
Which style does your team use?
https://github.com/GoogleContainerTools/jib?tab=readme-ov-file#quickstart

  • Maven
  • Gradle
  • Jib Core
  • Jib CLI

Guessing Maven like
https://github.com/GoogleContainerTools/jib/tree/master/examples/helloworld
mvn compile jib:build

GitHub

๐Ÿ— Build container images for your Java applications. - GoogleContainerTools/jib

GitHub

๐Ÿ— Build container images for your Java applications. - GoogleContainerTools/jib

#

Do y'all execute your JIB builds on Google Cloud Run or locally or both?

vivid rain
#

That's great to hear! Yes currently it's using that style, mvn compile jib:build

#

I believe the JIB builds are just done local now. We have a fully self-managed k8 cluster so ideally we would port the execution to that.

wispy nacelle
#

got it. Do you push images direct to a registry or create tarballs that you then work with?

vivid rain
#

Direct to registry

wispy nacelle
#

Got it. Is there a project that we can look at? Or is one of the examples in the repo above a good proxy?

vivid rain
#

The hello-world above is a fine example.

wispy nacelle
vivid rain
#

Thank you!

wispy nacelle
#

Given that the Java SDK is still experimental, which SDK would be best?

Go, Python, TypeScript?

vivid rain
#

Go

wispy nacelle
#

here's my process:

mkdir jib-test; cd jib-test
dagger init --sdk go

replace main.go with

// A test of JIB build

package main

import (
    "dagger/jib-test/internal/dagger"
)

type JibTest struct{}

// Publishes image to ttl.sh and returns Dagger Container - all built with Jib
func (m *JibTest) JibBuild(source *dagger.Directory) *dagger.Container {
    var opts = dagger.ContainerOpts{Platform: dagger.Platform("linux/amd64")}

    build := dag.Container(opts).
        From("maven:3-jdk-11").
        WithMountedDirectory("/mnt", source).
        WithWorkdir("/mnt").
        // build and push to ttl.sh/jpadams/image-built-with-jib
        WithExec([]string{"mvn", "compile", "jib:build"}).
        // build and write tarball to /mnt/target/image-built-with-jib.tar
        WithExec([]string{"mvn", "compile", "jib:buildTar"})
        
    return dag.Container(opts).
        // turns the tarball into a proper Dagger Container
        Import(build.File("/mnt/target/image-built-with-jib.tar"))
}
#

Then have some fun:

dagger call jib-build --source https://github.com/jpadams/jib\#master:examples/helloworld with-exec --args "" --use-entrypoint stdout 

(issue proposing a way to sweeten this ๐Ÿ‘† up https://github.com/dagger/dagger/issues/8335)

docker run --platform linux/amd64 ttl.sh/jpadams/image-built-with-jib
#
dagger call jib-build --source https://github.com/jpadams/jib\#master:examples/helloworld terminal --cmd bash

now you're in a terminal inside the built container!
try running the entrypoint yourself ๐Ÿ™‚

java -cp /app/resources:/app/classes:/app/libs/* example.HelloWorld
#

After playing with Jib a bit, I'd probably convert the Jib builds to pure Dagger, but also we can happily coexist with them.

Could be generalized into a nice module for all sorts of Jib build and publish stuff ๐Ÿ™‚

vivid rain
#

Thank you very much Jeremy!! I will try to play with this soon ๐Ÿ˜ƒ