2.1.0
With this release it is possible to define Dockerfiles in a fluent API and build them on the fly. It is possible to build new images and create new containers within the same fluent build. This release also comes with support for querying images from the host service.
Checkout the FluentMultiContainerTests to se the build in action:
using (var services = new Builder()
// Define custom node image to be used
.DefineImage("mariotoffia/nodetest")
.ReuseIfAlreadyExists()
.DefineFrom("ubuntu").Maintainer("Mario Toffia <mario.toffia@gmail.com>")
.Run("apt-get update &&",
"apt-get -y install curl &&",
"curl -sL https://deb.nodesource.com/setup | sudo bash - &&",
"apt-get -y install python build-essential nodejs")
.Run("npm install -g nodemon")
.Add("embedded:Ductus.FluentDockerTest/Ductus.FluentDockerTest.MultiContainerTestFiles/package.txt",
"/tmp/package.json")
.Run("cd /tmp && npm install")
.Run("mkdir -p /src && cp -a /tmp/node_modules /src/")
.UseWorkDir("/src")
.Add("index.js", "/src")
.ExposePorts(8080)
.Command("nodemon", "/src/index.js").Builder()
// Redis Db Backend
.UseContainer().WithName("redis").UseImage("redis").Builder()
// Node server 1 & 2
.UseContainer().WithName("node1").UseImage("mariotoffia/nodetest").Link("redis").Builder()
.UseContainer().WithName("node2").UseImage("mariotoffia/nodetest").Link("redis").Builder()
// Nginx as load balancer
.UseContainer().WithName("nginx").UseImage("nginx")
.Link("node1", "node2").CopyOnStart(nginx, "/etc/nginx/nginx.conf").ExposePort(80).Builder()
.Build().Start())
{
Assert.AreEqual(4, services.Containers.Count);
var ep = services.Containers.First(x => x.Name == "nginx").ToHostExposedEndpoint("80/tcp");
Assert.IsNotNull(ep);
var round1 = $"http://{ep.Address}:{ep.Port}".Wget();
Assert.AreEqual("This page has been viewed 1 times!",round1);
var round2 = $"http://{ep.Address}:{ep.Port}".Wget();
Assert.AreEqual("This page has been viewed 2 times!", round2);
}