Class OfficeFloorDockerUtil

java.lang.Object
net.officefloor.docker.test.OfficeFloorDockerUtil

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

    • OfficeFloorDockerUtil

      public OfficeFloorDockerUtil()
  • Method Details

    • getImageQualifiedName

      public static String getImageQualifiedName(String imageName, String defaulTagName) throws Exception

      Obtains the image name qualified with appropriate tag name.

      This allows overriding the default tag name with a configured file on the class path for the image name.

      Parameters:
      imageName - Name of the image.
      defaulTagName - Default tag name if no overriding configuration.
      Returns:
      Qualified image name.
      Throws:
      Exception - If fails to load configured tag name.
    • ensureNetworkAvailable

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

      public static void ensureImageAvailable(String imageName, String defaultTagName, OfficeFloorDockerUtil.BuildDirectoryFactory buildDirectoryFactory) throws 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.
      defaultTagName - Default tag name.
      buildDirectoryFactory - OfficeFloorDockerUtil.BuildDirectoryFactory to use if image not built.
      Throws:
      Exception - If fails to ensure the image is available.
    • ensureContainerAvailable

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