-
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
Changes from 5 commits
79df664
6156128
92b0f37
b04efa5
a08a4bb
0139615
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 layer(List<Path> files, Path pathInContainer)` | ||
- `JibContainerBuilder layer(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)` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weren't we talking about having a more fluent-looking There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scratch that - I'll rework this with the setters changed into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, but for setters like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And just There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
- `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")); | ||
``` |
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.
These two were changed to
addLayer
, 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.
Yep, I'll change this over.