Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: How to handle Jib build directly to registry. #1124

Closed
coollog opened this issue Oct 8, 2018 · 11 comments
Closed

Proposal: How to handle Jib build directly to registry. #1124

coollog opened this issue Oct 8, 2018 · 11 comments

Comments

@coollog
Copy link
Contributor

coollog commented Oct 8, 2018

Currently, Jib can build to the Docker daemon and share the same logic as the rest of the local builders (docker and bazel):

local.go#buildArtifact performs a series of steps for a build:

  1. b.runBuildForArtifact builds to the Docker daemon and gets the initial tag
  2. docker.Digest gets the digest for the initial tag from the Docker daemon
  3. tagger.GenerateFullyQualifiedImageName generates the intended tag
  4. b.api.ImageTag retags the initial tag to the intended tag
  5. if push=true, docker.RunPush pushes the intended tag

However, to leverage the full benefits of Jib, we would need to add the ability to call jib:build to build directly to the registry. The implementation logic would be very similar to how the kaniko builder works:

  1. Generate initial tag as random ID.
  2. Run jib:build to initial tag.
  3. docker.RemoteDigest to get the digest
  4. tagger.GenerateFullyQualifiedImageName to get the intended tag
  5. docker.AddTag to retag with intended tag

The original plan was the perform this logic when local.push=true, but we're proposing a new builder type jib (only supports JibMavenArtifact and JibGradleArtifact).

Therefore, the following would be what users could do with the Jib artifacts:

  • local and push=false - jib:dockerBuild builds to Docker daemon
  • local and push=true - jib:dockerBuild builds to Docker daemon and then the image is pushed
  • jib - jib:build builds directly to the registry

The caveat, though, is that the jib builder would not support other artifact types. The alternative is to just keep the original approach, where users could do:

  • local and push=false - jib:dockerBuild builds to Docker daemon
  • local and push=true - jib:build builds directly to the registry

@GoogleContainerTools/java-tools @GoogleContainerTools/container-tools

@chanseokoh
Copy link
Member

chanseokoh commented Oct 8, 2018

It makes me wonder what exactly this "Jib artifact" is? Is it tangible? Does it have a unique property that distinguish it form other types of artifacts?

@coollog
Copy link
Contributor Author

coollog commented Oct 8, 2018

The JibMavenArtifact and JibGradleArtifact defines what type of project it is (Maven or Gradle) and the module/subproject name, whereas the jib builder type defines to build using jib:build (vs jib:dockerBuild for the local builder type).

@chanseokoh
Copy link
Member

The JibMavenArtifact and JibGradleArtifact defines what type of project it is (Maven or Gradle) and the module/subproject name

JibMavenProject or JibMavenProjectStructure may be a more apt name then. Can we call it that way?
Or, is this an internal framework thing in that we have no choice but to adhere to the word "artifact"? An artifact sounds like it is a concrete output that you can carry around, so I think it can be a bit confusing.

@coollog
Copy link
Contributor Author

coollog commented Oct 8, 2018

It is named like the other config.Artifact types DockerArtifact and BazelArtifact. The "artifact" portion refers to the fact that the project will be used by Skaffold to build an output artifact.

@balopat
Copy link
Contributor

balopat commented Oct 8, 2018

There is no clear agreement yet where we will be heading with the builders/artifacts - I believe it's a confusing situation. See: #953 and #955.

I would not put this on the critical path for Jib yet. I think we should go with the jib builder as a local builder for now even if it's not the most optimal flow for jib yet and when we reshuffle the builder/artifact structure, we can rethink how a more optimal jib flow fits in.

The artifact name is misleading I agree - it refers more to an "descriptor format" like Dockerfile for docker, or bazel files for bazel or pom.xml and build.gradle for jibMaven and jibGradle...

@balopat
Copy link
Contributor

balopat commented Oct 8, 2018

@dgageot
@dlorenc
any thoughts?

@dgageot
Copy link
Contributor

dgageot commented Oct 9, 2018

I'm +1000 on just keeping the original approach based on push=true|false

In a project with multiple artifacts, we want a builder to be able to build all the artifacts. It's already not always the case. Let's not make it worth.

I can see myself working on a backend in Java built with Jib and a front end in Node built with Docker

@coollog
Copy link
Contributor Author

coollog commented Oct 9, 2018

@dgageot Do you mean keeping the original approach as in the current approach (as implemented) of:

  • local and push=false - jib:dockerBuild builds to Docker daemon
  • local and push=true - jib:dockerBuild builds to Docker daemon and Skaffold pushes to registry

Or the original "proposed" approach of:

  • local and push=false - jib:dockerBuild builds to Docker daemon
  • local and push=true - jib:build builds directly to the registry

@dgageot
Copy link
Contributor

dgageot commented Oct 9, 2018

The latter seems good to me

@coollog
Copy link
Contributor Author

coollog commented Oct 9, 2018

Okay, for that approach, then, we would deviate from the normal local builder logic and perform the steps like the kaniko builder:

  1. Generate initial tag as random ID.
  2. Run jib:build to initial tag.
  3. docker.RemoteDigest to get the digest
  4. tagger.GenerateFullyQualifiedImageName to get the intended tag
  5. docker.AddTag to retag with intended tag

@dgageot
Copy link
Contributor

dgageot commented Oct 9, 2018

I think it makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants