Skip to content

Releases: mariotoffia/FluentDocker

WaitFor custom Lambda Support

03 Oct 16:12
Compare
Choose a tag to compare

This release adds a possibility to have one or more custom lambdas to do the wait and thus it is possible to e.g. do a db connection and wait until it succeeds.

For example, it is possible to do this custom action:

      // @formatter:off
      using (new Builder()
                .UseContainer()
                .UseCompose()
                .FromFile(file)
                .RemoveOrphans()
                .Wait("wordpress", (service, cnt) => {
                    if (cnt > 60) throw new FluentDockerException("Failed to wait for wordpress service");
            
                    var res = HttpExtensions.DoRequest("http://localhost:8000/wp-admin/install.php").Result;            
                    return (res.Code == HttpStatusCode.OK && 
                            res.Body.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1) ? 0 : 500;
                  })
                .Build().Start())
        // @formatter:on
      {
        // Since we have waited - this shall now always work.       
        var installPage = await "http://localhost:8000/wp-admin/install.php".Wget();
        Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
      }

(this is basically a more cumbersome version of WaitForHttp but it illustrates the point).

Also the container builder now also have the WaitForHttp and Wait (and not only compose).

Cheers,
Mario

Sudo support

03 Oct 12:38
Compare
Choose a tag to compare

This is a experimental release to allow for sudo support on Linux and Mac.

For Linux and Mac users there are several options how to authenticate towards the socket. FluentDocker supports no sudo, sudo without any password (user added as NOPASSWD in /etc/sudoer), or
sudo with password. The default is that FluentDocker expects to be able to talk without any sudo. The options ar global but can be changed in runtime.

     SudoMechanism.None.SetSudo(); // This is the default
     SudoMechanism.Password.SetSudo("<my-sudo-password>");
     SudoMechanism.NoPassword.SetSudo();

This is still experimental and will probably change to e.g SecureString or other in the future.

New Features on Docker Compose Fluent API

02 Oct 16:30
Compare
Choose a tag to compare

This release adds a new Wait method called WaitForHttp. It uses one of HTTP POST, GET, PUT, DELETE with or without body to perform it's wait. In addition it is possible to add a lambda to determine if e.g. responses are OK or if it should abandon wait.

In addition compose fluent API now supports:

  • ExportOnDispose
  • ExportExploadedOnDispose
  • CopyOnStart
  • CopyOnDispose
  • WaitForPort
  • WaitForProcess
  • ExecuteOnRunning
  • ExecuteOnDisposing

In order to use those functions, you have to name the container name and therefore it is possible to address several containers in same compose project. For example it is possible to do e.g. this:

      var file = Path.Combine(Directory.GetCurrentDirectory(),
        (TemplateString) "Resources/ComposeTests/WordPress/docker-compose.yml");

      // @formatter:off
      using (new Builder()
                .UseContainer()
                .UseCompose()
                .FromFile(file)
                .RemoveOrphans()
                .WaitForHttp("wordpress",  "http://localhost:8000/wp-admin/install.php", continuation: (resp, cnt) =>  
                             resp.Body.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1 ? 0 : 500)
                .Build().Start())
        // @formatter:on
      {
        // Since we have waited - this shall now always work.       
        var installPage = await "http://localhost:8000/wp-admin/install.php".Wget();
        Assert.IsTrue(installPage.IndexOf("https://wordpress.org/", StringComparison.Ordinal) != -1);
      }

This example waits until it gets a specific response from the wordpress container. There are a few more in the unit test section.

Align Ssh API with fluent Machine API

29 Sep 14:25
Compare
Choose a tag to compare

Now you can define container or new image directly under the ssh in order to allow for multiple external daemons in same fluent definition.

Also Updated documentation.

Remote Docker Connection Definition Support

29 Sep 07:14
Compare
Choose a tag to compare

It is now possible to define a remote SSH connection to a docker daemon. For example:

using (
        var container =
          new Builder().UseHost()
            .UseSsh("192.168.1.27").WithName("remote-daemon")
            .WithSshUser("solo").WithSshKeyPath("${E_LOCALAPPDATA}/lxss/home/martoffi/.ssh/id_rsa").Host()
            .UseContainer()
            .UseImage("postgres:9.6-alpine")
            .WithEnvironment("POSTGRES_PASSWORD=mysecretpassword")
            .Build())
      {
        Assert.AreEqual(ServiceRunningState.Stopped, container.State);
      }

Creates a remote connection called remote-daemon. It uses WSL on windows, therefore the ssh keypath is in lxx but on Linux and Mac it should be along the lines of ~/.ssh/id_rsa. Please Check the section arount Connecting to Remote Docker Daemons (https://github.com/mariotoffia/FluentDocker#connecting-to-remote-docker-daemons) for more information.

This do address the task #60 as well.

Cheers,
Mario

Compose Port Bugfix

27 Sep 13:29
Compare
Choose a tag to compare

Small bugfix to fix issue #60.

Bugfix & Small Feature Release

18 Sep 19:15
Compare
Choose a tag to compare

This release fixes a few bugs and adds small fetures such as the ability to handle

  • Container Memory Management Options
  • Container Identification Options
  • Block I/O Constraints, Privileged Options
  • Networks settings Options

Added a property on the IContainerService called Image. It reflects the image of the current runtime container.

It also fixes spaces in paths in many places such as docker-compose, mount, working directory etc. It also handles / as neutral path and thus is translated to __ in windows.

Untested docker-compose service where a service is handling docker-compose docker container life-cycle. It also has a fluent API to model up such service. However, it is in alpha and things may change when 3.0.0 is released.

Cheers,
Mario

Spaces in compose path bug fix

06 Aug 09:52
Compare
Choose a tag to compare

This release fixes so it is possible to have spaces in the path to compose files. It also gives the ability to use --memory in docker run commands.

Logging & Restart Policy

20 Jul 09:21
Compare
Choose a tag to compare

This minor release adds the ability hard control if it shall log or not. In addition it supports RestartPolicy when doing a Docker run. The supported policies are

  1. OnFailure
  2. UnlessStopped
  3. Always

Thus it is possible to e.g. do a restart always policy when running:

var cmd = _docker.Run("postgres:9.6-alpine", new ContainerCreateParams
        {
          PortMappings = new[] {"40001:5432"},
          RestartPolicy = RestartPolicy.Always,
          Environment = new[] {"POSTGRES_PASSWORD=mysecretpassword"}
        }, _certificates);

This release is associated with task #49 and #50

Bugfix and small performance fix

02 Jul 11:47
Compare
Choose a tag to compare

This release fixes a bug when discovering already running containers. If such is the case, the handling around disposal is never configured and could result in containers being deleted. It also alters the behavior on Host.Discover where docker machine may be omitted completely by settingpreferNativeDocker = true.

Cheers,
Mario