Class OfficeFloorDockerUtil


  • public class OfficeFloorDockerUtil
    extends java.lang.Object
    Docker wrapper for running third party services (typically for testing).
    Author:
    Daniel Sagenschneider
    • Constructor Detail

      • OfficeFloorDockerUtil

        public OfficeFloorDockerUtil()
    • Method Detail

      • ensureNetworkAvailable

        public static DockerNetworkInstance ensureNetworkAvailable​(java.lang.String networkName)
                                                            throws java.lang.Exception
        Ensures the docker network is available.
        Parameters:
        networkName - Network name.
        Returns:
        DockerNetworkInstance of manage docker network.
        Throws:
        java.lang.Exception - If fails to ensure docker network available.
      • ensureImageAvailable

        public static void ensureImageAvailable​(java.lang.String imageName,
                                                OfficeFloorDockerUtil.BuildDirectoryFactory buildDirectoryFactory)
                                         throws java.lang.Exception
        Ensures the image is available. If not, will build image from input build directory.
        Parameters:
        imageName - Name of image to check exists or build.
        buildDirectoryFactory - OfficeFloorDockerUtil.BuildDirectoryFactory to use if image not built.
        Throws:
        java.lang.Exception
      • ensureContainerAvailable

        public static DockerContainerInstance ensureContainerAvailable​(java.lang.String containerName,
                                                                       java.lang.String imageName,
                                                                       java.util.function.Function<com.github.dockerjava.api.DockerClient,​com.github.dockerjava.api.command.CreateContainerCmd> createContainer)
                                                                throws java.lang.Exception
        Ensures the docker container is available.
        Parameters:
        containerName - Name of docker container.
        imageName - Name of the docker image.
        createContainer - Factory for the CreateContainerCmd if container not running.
        Returns:
        DockerContainerInstance to manage running docker container.
        Throws:
        java.lang.Exception - If fails to ensure docker container available.