mariotoffia / FluentDocker

Use docker, docker-compose local and remote in tests and your .NET core/full framework apps via a FluentAPI
Apache License 2.0
1.31k stars 97 forks source link

How to pass multiple compose files like -f <file> -f <other file>? #281

Open ci-vamp opened 1 year ago

ci-vamp commented 1 year ago

here is what i am trying to accomplish

docker-compose --project-directory ./docker -f docker-compose.yml -f docker-compose.prod.yml up

got the following exception

Unhandled exception. Ductus.FluentDocker.Common.FluentDockerException: Could not dispose composite service from file(s) docker-compose.yml, docker-compose.prod.yml

attempt with fluent docker

using Ductus.FluentDocker.Services;
using Ductus.FluentDocker.Services.Impl;
using Ductus.FluentDocker.Model.Compose;

var hosts = new Hosts().Discover();
var _docker = hosts.FirstOrDefault(host => host.IsNative) ?? hosts.FirstOrDefault(host => host.Name == "default");

var composeConfig = new DockerComposeConfig
{
    ProjectDirectory = Path.Combine(Directory.GetCurrentDirectory(), "docker"),
    ComposeFilePath = new List<string> { "docker-compose.yml", "docker-compose.prod.yml" },
    ForceRecreate = true,
    RemoveOrphans = true,
    StopOnDispose = true,
};

using (var serviceManager = new DockerComposeCompositeService(_docker, composeConfig))
{
    foreach (var container in serviceManager.Containers)
    {
        Console.WriteLine(container.Name);
    }
}
mariotoffia commented 1 year ago

Thanks @ms-vamp for your bug report! I'll add it to my long todo list - but this one should be fairly simple to fix.

Cheers, Mario :)