-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 RFC: Jib Core as a library for Java #987
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
79df664
Adds proposal for Jib Core library.
coollog 6156128
Merge branch 'master' into jib-core-proposal
coollog 92b0f37
Finishes proposal for Jib Core.
coollog b04efa5
addCredential
coollog a08a4bb
Adds Jib#from(RegistryImage).
coollog 0139615
addLayer
coollog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Proposal: Jib Core as a library for Java | ||
|
||
The tracking issue is at [#337](https://github.com/GoogleContainerTools/jib/issues/337). | ||
|
||
# Goal | ||
|
||
Design for Jib Core as a Java library for building container images. | ||
|
||
# Proposed API | ||
|
||
`Jib` - the main entrypoint for using Jib Core | ||
- `JibContainerBuilder from(String baseImageReference)` | ||
- `JibContainerBuilder from(ImageReference baseImageReference)` | ||
- `JibContainerBuilder from(RegistryImage baseImage)` | ||
|
||
`JibContainerBuilder` - configures the container to build | ||
- `JibContainerBuilder addLayer(List<Path> files, Path pathInContainer)` | ||
- `JibContainerBuilder addLayer(LayerConfiguration)` | ||
- `JibContainerBuilder setLayers(List<LayerConfiguration>/LayerConfiguration...)` | ||
|
||
- `JibContainerBuilder setEntrypoint(List<String>/String...)` | ||
- `JibContainerBuilder setProgramArguments(List<String>/String...)` | ||
- `JibContainerBuilder setEnvironment(Map<String, String> environmentMap)` | ||
- `JibContainerBuilder addEnvironmentVariable(String name, String value)` | ||
- `JibContainerBuilder setExposedPorts(List<Port>/Port...)` | ||
- `JibContainerBuilder addExposedPort(Port port)` | ||
- `JibContainerBuilder setLabels(Map<String, String> labelMap)` | ||
- `JibContainerBuilder addLabel(String key, String value)` | ||
- `JibContainer containerize(Containerizer)` | ||
|
||
Three `TargetImage` types (`RegistryImage`, `DockerDaemonImage`, and `TarImage`) define the 3 different targets Jib can build to. | ||
|
||
`RegistryImage` - builds to a container registry | ||
- `static RegistryImage named(ImageReference/String)` | ||
- `RegistryImage addCredential(String username, String password)` | ||
- `RegistryImage addCredentialRetriever(CredentialRetriever)` | ||
|
||
`DockerDaemonImage` - builds to a Docker daemon | ||
- `static DockerDaemonImage named(ImageReference/String)` | ||
- `DockerDaemonImage setDockerExecutable(Path)` | ||
|
||
`TarImage` - builds to a tarball archive | ||
- `Builder` | ||
- `TarImage saveTo(Path outputFile)` | ||
- `static Builder named(ImageReference/String)` | ||
|
||
`Containerizer` - configures how and where to containerize to | ||
TadCordle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- `static Containerizer to(RegistryImage)` | ||
- `static Containerizer to(DockerDaemonImage)` | ||
- `static Containerizer to(TarImage)` | ||
- `Containerizer setExecutorService(ExecutorService)` | ||
- `Containerizer setCacheConfiguration(CacheConfiguration)` | ||
- `Containerizer setEventHandlers(EventHandlers)` | ||
|
||
## For Java containers | ||
|
||
`JavaContainerBuilder` - builds a `JibContainerBuilder` for Java apps | ||
- `static JavaContainerBuilder builder()` | ||
- `JavaContainerBuilder addDependencies(List<Path> dependencyFiles)` | ||
- `JavaContainerBuilder addResources(List<Path> resourceFiles)` | ||
- `JavaContainerBuilder addClasses(List<Path> classFiles)` | ||
- `JavaContainerBuilder addToClasspath(List<Path> otherFiles)` | ||
- `JavaContainerBuilder setJvmFlags(List<String>/String... jvmFlags)` | ||
- `JavaContainerBuilder setMainClass(String mainClass)` | ||
- `JavaContainerBuilder toContainerBuilder()` | ||
|
||
# Simple example | ||
|
||
```java | ||
Jib.from("busybox") | ||
.addLayer(Arrays.asList(Paths.get("helloworld.sh")), "/helloworld.sh") | ||
.setEntrypoint("/helloworld.sh") | ||
.containerize( | ||
Jib.to(RegistryImage.named("coollog/jibtestimage") | ||
.setCredential("coollog", "notmyrealpassword")); | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weren't we talking about having a more fluent-looking
environment()
,labels()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that was in #953 - I'll update these to reflect the proposal there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, after changing this over, I feel like the way we have it now is clearer, since there's a combination ofset...
andadd...
methods and removing the prefixes may be confusing since most of theset...
methods mean "replace with" rather than "append".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that - I'll rework this with the setters changed into the
...Only
names.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but for setters like
setLayers
,layersOnly
or the like doesn't sound right.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And just
layers
is unclear as to whether it appends or replaces.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't think we ever replace layers, do we. At least, not for the API. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setLayers
currently would actually replace layers (https://github.com/GoogleContainerTools/jib/blob/master/jib-core/src/main/java/com/google/cloud/tools/jib/api/JibContainerBuilder.java#L109)