Continuous Deployment with Docker and Virgo

Continuous Deployment with Docker and Virgo

Docker LogoThe post “Automated installation of Virgo with Docker” described how to build and run a Docker container with Virgo inside.

Today I’ll describe an easy way of continuously deploying applications into such a Virgo running inside an isolated Docker container.

In a regular Virgo installation we would simply drop our application bundle into the pickup folder of the targeted Virgo instance. We could allow the Docker container to reach out into the filesystem of the host, but to keep the isolation on a high level we want to use a file upload. The idea is to provide an upload servlet that hands over the payload to the Virgo deployer via JMX.

The implementation of this file upload controller is pretty straightforward:

public class FileUploadController {
  @RequestMapping(value = "/upload", method = RequestMethod.POST)
  public @ResponseBody
  String handleFileUpload(@RequestParam("name") String name, @RequestParam("file") MultipartFile file) {"Handling file upload {}...", name);
    URI uri = acceptMultipartFile(file);
    Object invoke = this.mBeanServer.invoke(objectName, "deploy", new Object[] { uri.toString() },
                                                new String[] { String.class.getName() });"Deployment of {} finished.", name);

Just before the default command of the Docker container, we assure that the point of acceptance is available:

# install “point of acceptance”
ADD /home/virgo/pickup/

# default command
CMD su - virgo /home/virgo/bin/

Not much left to do. Create the Docker image:

$ sudo docker build -t eclipsesource/tabris-jetty-farm .

Fire up a Docker container…

$ sudo docker run -i -h localhost -p 28081:8080 -t eclipsesource/tabris-jetty-farm

That’s it! You are ready to trigger continuous deployment as final step of your CI job:

$ curl -F "name=/tmp/app.jar" -F "file=@${PROJ_ROOT}/target/com.eclipsesource.tabris.demos_1.2.0.20131018-1406.jar" https://localhost:28081/farm/upload/

What’s next? I an future post I will explore the possibilities to programmatically build Docker images as well as create, start and stop Docker containers with the Docker Remote API[1] and docker-java[2].

[ Using Virgo in an industrial setting? Our technology subscription secures your investment for years to come. ]

[1] Docker Remote API –
[2] docker-java –