Class DockerRemoteTerminal
- java.lang.Object
-
- com.oracle.bedrock.runtime.docker.DockerRemoteTerminal
-
- All Implemented Interfaces:
com.oracle.bedrock.Option,Deployer,RemoteTerminal
public class DockerRemoteTerminal extends Object implements RemoteTerminal, Deployer
A specializedRemoteTerminalused to generate Docker images and launch Docker containers from those images.Copyright (c) 2016. All Rights Reserved. Oracle Corporation.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.- Author:
- Jonathan Knight
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDockerRemoteTerminal.ContainerApplicationAn implementation of anApplicationthe sole purpose of which is to be able to capture theApplicationProcess.static classDockerRemoteTerminal.ContainerMetaClassTheMetaClassthat is used when starting a Docker container application.-
Nested classes/interfaces inherited from interface com.oracle.bedrock.Option
com.oracle.bedrock.Option.Collectable, com.oracle.bedrock.Option.Collector<C extends com.oracle.bedrock.Option.Collectable,T extends com.oracle.bedrock.Option.Collector<C,T>>
-
Nested classes/interfaces inherited from interface com.oracle.bedrock.runtime.remote.RemoteTerminal
RemoteTerminal.Launchable
-
-
Constructor Summary
Constructors Constructor Description DockerRemoteTerminal(com.oracle.bedrock.runtime.Platform platform)Construct a newDockerRemoteTerminal.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DockerImagecreateImage(String imageTag, File dockerFile, Docker docker, com.oracle.bedrock.OptionsByType optionsByType)Create a Docker image.DeployedArtifactsdeploy(List<DeploymentArtifact> artifactsToDeploy, String remoteDirectory, com.oracle.bedrock.runtime.Platform platform, com.oracle.bedrock.Option... deploymentOptions)RemoteApplicationProcesslaunch(RemoteTerminal.Launchable launchable, Class<? extends com.oracle.bedrock.runtime.Application> applicationClass, com.oracle.bedrock.OptionsByType optionsByType)voidmakeDirectories(String directoryName, com.oracle.bedrock.OptionsByType optionsByType)Write any mkdir commands to the Dockerfileprotected com.oracle.bedrock.runtime.ApplicationProcessrunContainer(String containerName, RemoteTerminal.Launchable launchable, DockerImage image, Docker docker, com.oracle.bedrock.OptionsByType optionsByType)Run a container using the specified image.DeployedArtifactsundeploy(DeployedArtifacts deployedArtifacts, com.oracle.bedrock.runtime.Platform platform, com.oracle.bedrock.Option... deploymentOptions)protected FilewriteDockerFile(RemoteTerminal.Launchable launchable, String baseImage, com.oracle.bedrock.OptionsByType optionsByType)Write a Dockerfile that can be used to run the application.
-
-
-
Constructor Detail
-
DockerRemoteTerminal
public DockerRemoteTerminal(com.oracle.bedrock.runtime.Platform platform)
Construct a newDockerRemoteTerminal.- Parameters:
platform- thePlatformthe commands will run on
-
-
Method Detail
-
deploy
public DeployedArtifacts deploy(List<DeploymentArtifact> artifactsToDeploy, String remoteDirectory, com.oracle.bedrock.runtime.Platform platform, com.oracle.bedrock.Option... deploymentOptions)
-
undeploy
public DeployedArtifacts undeploy(DeployedArtifacts deployedArtifacts, com.oracle.bedrock.runtime.Platform platform, com.oracle.bedrock.Option... deploymentOptions)
-
makeDirectories
public void makeDirectories(String directoryName, com.oracle.bedrock.OptionsByType optionsByType)
Write any mkdir commands to the Dockerfile- Specified by:
makeDirectoriesin interfaceRemoteTerminal- Parameters:
directoryName- the directory to createoptionsByType- theOptionsByTypecontrolling the build of the Dockerfile
-
launch
public RemoteApplicationProcess launch(RemoteTerminal.Launchable launchable, Class<? extends com.oracle.bedrock.runtime.Application> applicationClass, com.oracle.bedrock.OptionsByType optionsByType)
- Specified by:
launchin interfaceRemoteTerminal
-
writeDockerFile
protected File writeDockerFile(RemoteTerminal.Launchable launchable, String baseImage, com.oracle.bedrock.OptionsByType optionsByType) throws IOException
Write a Dockerfile that can be used to run the application.- Parameters:
launchable- theRemoteTerminal.Launchableto usebaseImage- the name of the base image to use in the Dockerfile FROM statementoptionsByType- theOptionsByTypeto use- Returns:
- the
Filerepresenting the Dockerfile created - Throws:
IOException- if there is an error writing the Dockerfile
-
createImage
protected DockerImage createImage(String imageTag, File dockerFile, Docker docker, com.oracle.bedrock.OptionsByType optionsByType)
Create a Docker image.The image will contain all of the required artifacts to run the application. The image will be tagged with a random UUID.
- Parameters:
imageTag- the tag to apply to the imagedockerFile- the Dockerfile to use to build the imagedocker- theDockerenvironment to useoptionsByType- theOptionsByTypeto use- Returns:
- a
DockerImagerepresenting the built image
-
runContainer
protected com.oracle.bedrock.runtime.ApplicationProcess runContainer(String containerName, RemoteTerminal.Launchable launchable, DockerImage image, Docker docker, com.oracle.bedrock.OptionsByType optionsByType)
Run a container using the specified image.- Parameters:
containerName- the name of the containerlaunchable- theRemoteTerminal.Launchablethat will give the command to executeimage- the image to use to run the containerdocker- theDockerenvironment to useoptionsByType- theOptionsByTypeto use- Returns:
- a
DockerContainerrepresenting the running image
-
-