/** * Creates a new {@link JavaContainerBuilder} with the specified base image. * * @param registryImage the {@link RegistryImage} that defines base container registry and * credentials * @return a new {@link JavaContainerBuilder} */ public static JavaContainerBuilder from(RegistryImage registryImage) { return new JavaContainerBuilder(Jib.from(registryImage)); }
/** * Creates a new {@link JavaContainerBuilder} that uses distroless java as the base image. For * more information on {@code gcr.io/distroless/java}, see <a * href="https://github.com/GoogleContainerTools/distroless">the distroless repository</a>. * * @return a new {@link JavaContainerBuilder} * @throws InvalidImageReferenceException if creating the base image reference fails * @see <a href="https://github.com/GoogleContainerTools/distroless">The distroless repository</a> */ public static JavaContainerBuilder fromDistroless() throws InvalidImageReferenceException { return from(RegistryImage.named("gcr.io/distroless/java")); }
/** * Starts building the container from a base image. The base image should be publicly-available. * For a base image that requires credentials, use {@link #from(RegistryImage)}. * * @param baseImageReference the base image reference * @return a new {@link JibContainerBuilder} to continue building the container */ public static JibContainerBuilder from(ImageReference baseImageReference) { return new JibContainerBuilder(RegistryImage.named(baseImageReference)); }
/** * Starts building the container from a base image. The base image should be publicly-available. * For a base image that requires credentials, use {@link #from(RegistryImage)}. * * @param baseImageReference the base image reference * @return a new {@link JibContainerBuilder} to continue building the container * @throws InvalidImageReferenceException if the {@code baseImageReference} is not a valid image * reference */ public static JibContainerBuilder from(String baseImageReference) throws InvalidImageReferenceException { return from(RegistryImage.named(baseImageReference)); }
/** * Gets a new {@link Containerizer} that containerizes to a Docker daemon. * * @param dockerDaemonImage the {@link DockerDaemonImage} that defines target Docker daemon * @return a new {@link Containerizer} */ public static Containerizer to(DockerDaemonImage dockerDaemonImage) { return new Containerizer(dockerDaemonImage); }
/** * Instantiate with the image reference to tag the built image with. This is the name that shows * up on the Docker daemon. * * @param imageReference the image reference * @return a new {@link DockerDaemonImage} * @throws InvalidImageReferenceException if {@code imageReference} is not a valid image reference */ public static DockerDaemonImage named(String imageReference) throws InvalidImageReferenceException { return named(ImageReference.parse(imageReference)); }
/** * Adds the contents of a resources directory to the image. * * @param resourceFilesDirectory the directory containing the project's resources * @param pathFilter filter that determines which files (not directories) should be added * @return this * @throws IOException if adding the layer fails */ public JavaContainerBuilder addResources(Path resourceFilesDirectory, Predicate<Path> pathFilter) throws IOException { return addDirectory(resourceFilesDirectory, RESOURCES_PATH, LayerType.RESOURCES, pathFilter); }
/** * Starts building the container from a base image. * * @param registryImage the {@link RegistryImage} that defines base container registry and * credentials * @return a new {@link JibContainerBuilder} to continue building the container */ public static JibContainerBuilder from(RegistryImage registryImage) { return new JibContainerBuilder(registryImage); }
/** * Sets the output file to save the tarball archive to. * * @param outputFile the output file * @return a new {@link TarImage} */ public TarImage saveTo(Path outputFile) { return new TarImage(imageReference, outputFile); } }
/** * Adds the contents of a resources directory to the image. * * @param resourceFilesDirectory the directory containing the project's resources * @return this * @throws IOException if adding the layer fails */ public JavaContainerBuilder addResources(Path resourceFilesDirectory) throws IOException { return addResources(resourceFilesDirectory, path -> true); }
/** * Instantiate with the image reference to use. * * @param imageReference the image reference * @return a new {@link RegistryImage} */ public static RegistryImage named(ImageReference imageReference) { return new RegistryImage(imageReference); }
/** * Configures the output tarball archive with an image reference. This image reference will be the * name of the image if loaded into the Docker daemon. * * @param imageReference the image reference * @return a {@link Builder} to finish constructing a new {@link TarImage} */ public static Builder named(ImageReference imageReference) { return new Builder(imageReference); }
/** * Instantiate with the image reference to tag the built image with. This is the name that shows * up on the Docker daemon. * * @param imageReference the image reference * @return a new {@link DockerDaemonImage} */ public static DockerDaemonImage named(ImageReference imageReference) { return new DockerDaemonImage(imageReference); }
/** * Adds the contents of a classes directory to the image. * * @param classFilesDirectory the directory containing the class files * @return this * @throws IOException if adding the layer fails */ public JavaContainerBuilder addClasses(Path classFilesDirectory) throws IOException { return addClasses(classFilesDirectory, path -> true); }
/** * Sets the layers. This replaces any previously-added layers. * * @param layerConfigurations the {@link LayerConfiguration}s * @return this */ public JibContainerBuilder setLayers(LayerConfiguration... layerConfigurations) { return setLayers(Arrays.asList(layerConfigurations)); }
/** * Creates a new {@link JavaContainerBuilder} with the specified base image reference. * * @param baseImageReference the base image reference * @return a new {@link JavaContainerBuilder} */ public static JavaContainerBuilder from(ImageReference baseImageReference) { return from(RegistryImage.named(baseImageReference)); }
/** * Gets a new {@link Containerizer} that containerizes to a tarball archive. * * @param tarImage the {@link TarImage} that defines target output file * @return a new {@link Containerizer} */ public static Containerizer to(TarImage tarImage) { return new Containerizer(tarImage); }
/** * Adds the contents of a classes directory to the image. * * @param classFilesDirectory the directory containing the class files * @param pathFilter filter that determines which files (not directories) should be added * @return this * @throws IOException if adding the layer fails */ public JavaContainerBuilder addClasses(Path classFilesDirectory, Predicate<Path> pathFilter) throws IOException { return addDirectory(classFilesDirectory, CLASSES_PATH, LayerType.CLASSES, pathFilter); }
/** * Creates a new {@link JavaContainerBuilder} with the specified base image reference. * * @param baseImageReference the base image reference * @return a new {@link JavaContainerBuilder} * @throws InvalidImageReferenceException if {@code baseImageReference} is invalid */ public static JavaContainerBuilder from(String baseImageReference) throws InvalidImageReferenceException { return from(RegistryImage.named(baseImageReference)); }
/** * Gets a new {@link Containerizer} that containerizes to a container registry. * * @param registryImage the {@link RegistryImage} that defines target container registry and * credentials * @return a new {@link Containerizer} */ public static Containerizer to(RegistryImage registryImage) { return new Containerizer(registryImage); }