Releases: mariotoffia/FluentDocker
Docker Compose V2 Auto Detection
This release brings three things:
- The CI/CD process is now purely in GitHub (GH Action)
- It ignores any compose version hints (this will be re-enabled when breaking change needs to be done) but uses
docker compose(subcommand) as preferred and reverts todocker-compose(if found). This solves Issue #312 - Nuget Release: netstandard2.0, net6.0, net8.0
I really hope I will have more time to fix and develop new features going forward!
Cheers,
Mario 😊
Docker-compose v2
Support for docker-compose v2 when using "standard" docker daemon. This is due to that docker-compose v2 do not support -H (uses docker context instead).
CVE-2021-39208 fix
Fixed CVE-2021-39208 by upgrading SharpCompress.
This requires to drop the support for netstandard1.6 since SharpCompress did drop it.
Please file an Issue if any problems occur due to this!
Cheers,
Mario :)
Minor enhancement & bugfix
Release notes
Features
Added Feature DeleteIfExist
DeleteIfExists(bool removeVolumes = true, bool force = false, string removeLink = null)It ensures that a container is deleted before creating. Hence the inverse ReuseIfExists().
var name = Guid.NewGuid().ToString();
var container = Fd.UseContainer()
.UseImage("postgres:9.6-alpine")
.WithName($"name-{name}")
.Build();
var id = container.Id;
using (var c = Fd
.UseContainer()
.DeleteIfExists()
.UseImage("postgres:9.6-alpine")
.WithName($"name-{name}")
.Build())
{
// Ids should not be equal - since deleted and then created.
AreNotEqual(id, c.Id);
}Added Created on Container configuration
This exposes the DateTime when the container was created.
Added Compose Project Directory
It is now possible to do UseProjectDirectory() in the CompositeBuilder to specify a project directory. This was implemented in PR #217 and brought up in Issue #216.
Examples
Added a Example solution to start showing some simple solutions instead of, possibly, complex unit test to understand how to use this library.
Notable PRs
PR #171 from Diggzinc/master
Simplified Trace and support for routing to any logging framework. For example, like this.
PR #200 from 0xced
Fixed bug: On macOS, tests running the envtest.sh script would fail with a permission denied exception because the script is not exectuable
PR #201/#204 from 0xced
Allow to PublishAllPortsinstead of explicit portmappings as a shorthand. Added ExposeAllPorts.
PR #202 from 0xced
Hide real exeption when throwOnError in a container export is fixed.
PR #203 from 0xced
Fixes many typos
PR #218 from jgozner
Added a Ductus.FluentDocker.XUnit NuGet package to be used when doing XUnit testing instead of mstest.
Security update for CVE-2018-8292
This is a fix for the CVE-2018-8292. See GitHUB Advisory for more information.
You're strongly advised to update to this release!
Bugfix release
This release fixes the COPY command in the docker file builder that did not double quote filenames in the JSON array.
Talking to custom docker daemon URI without docker-machine
Added a limited support to use the FluentAPI to talk to a remote docker daemon without using docker-machine. This is done either by manually creating a instance of a DockerHostService or use FromUri on HostBuilder.
using(var container = Fd.UseHost().
FromUri(Settings.DockerUri, isWindowsHost: true).
UseContainer().
Build())
{
}The above sample connects to a custom DockerUri from a setting and is a windows container docker daemon.
FromUrithat uses aDockerUrito create aIHostService. This uri is arbitrary. It also support other properties (see below).
public HostBuilder FromUri(
DockerUri uri,
string name = null,
bool isNative = true,
bool stopWhenDisposed = false,
bool isWindowsHost = false,
string certificatePath = null) {/*...*/}It will use "sensible" defaults on all parameters. Most of the case the uri is sufficient. For example if not providing the certificatePath it will try to get it from the environment DOCKER_CERT_PATH. If not found in the environment, it will default to none.
UseHostthat takes a instantiatedIHostServiceimplementation.
Support for Custom IPEndpoint Resolver
This release just adds a single functionality - Ability to provide with a custome endpoint resolver on a ContainerBuilder. This solves issue #107.
If the resolver returns null or is null on the container service, it will use the default mechanism to resolve the IP endpoint.
It can be used in the following manner.
using (
var container =
Fd.UseContainer()
.UseImage("postgres:9.6-alpine")
.WithEnvironment("POSTGRES_PASSWORD=mysecretpassword")
.ExposePort(5432)
.UseCustomResolver((
ports, portAndProto, dockerUri) =>
{
if (null == ports || string.IsNullOrEmpty(portAndProto))
return null;
if (!ports.TryGetValue(portAndProto, out var endpoints))
return null;
if (null == endpoints || endpoints.Length == 0)
return null;
if (CommandExtensions.IsNative())
return endpoints[0];
if (CommandExtensions.IsEmulatedNative())
return CommandExtensions.IsDockerDnsAvailable()
? new IPEndPoint(CommandExtensions.EmulatedNativeAddress(), endpoints[0].Port)
: new IPEndPoint(IPAddress.Loopback, endpoints[0].Port);
if (Equals(endpoints[0].Address, IPAddress.Any) && null != dockerUri)
return new IPEndPoint(IPAddress.Parse(dockerUri.Host), endpoints[0].Port);
return endpoints[0];
})
.WaitForPort("5432/tcp", 30000 /*30s*/)
.Build()
.Start())
{
var state = container.GetConfiguration(true/*force*/).State.ToServiceState();
Assert.AreEqual(ServiceRunningState.Running, state);
}Small feature & bugfix release
This release adds a few features and a handful of bugfixes.
Filebuilder
This Release adds a few enhancements to the FileBuilder to support all dockerfile commands an fixes a few bugs .
This adds the following commands:
- ENV
- ARG
- ENTRYPOINT
- LABEL
- USER
- VOLUME
Modified:
- FROM to accept both platform (such as linux/amd64) and a alias name. This name may be referred using other commands.
- COPY to accept chown user and group as well as --from=alias to refer to a earlier build step FROM ... AS alias.
Issues: #177 #178 and #179 via PR #180
-
It is now possible, in
ImageBuilderto doFrom(string imageAndTag, string asName)and hence render a FROM image:label AS myimage. -
Added simple support to provide an URL instead of a local filepath when using
FileBuilder. It will download the resource and add it to a COPY instruction.
var dockerfile = Fd.Dockerfile()
.UseParent("node:12.18.1")
.Environment("NODE_ENV=production")
.Run("npm install --production")
.Copy(
"https://www.my.com/path/myresource.js",
"/server.js")
.Copy("Resources/Issue/111/server.py", "/server.py")
.Command("node", "server.js").ToDockerfileString();The above example, copies the myresource.js from https://www.my.com/path to the docker container root /server.js.
- Ability to use UDP as exposed protocol.
Fd().UseContainer()
.UseImage("kiasaki/alpine-postgres")
.WithEnvironment($"POSTGRES_PASSWORD={PostgresPassword}")
.ExposePort(5432)
.ExposePort(8192,8800,"udp")
.WaitForPort("5432/tcp", 30000 /*30s*/);The ExposePort(int hostPort, int containerPort, string protocol = "tcp") defaults to tcp but can accept any protocol. Currently docker only support udp.
New Feature Release & Bugfixes
New Features
- @fbraun4358 Added support for network alias so it is possible to use both standard network and alias functionality PR #173
- @zplzk2 Allow user to specify "--ipc" within ContainerBuilder and Fluent API PR #167
- Support for core 3.1
- @sqeezy Added "Isolation" parameter for docker create PR #164
- @MindaugasLaganeckas Helped out to create a automated toolchain
- Added feature pass environment to compose PR #148
- @truepele Improved GetContainers performance PR #146
- @truepele Added ComposeUp: add no-start option; throw for incompatible options PR #142
- Added support for custom runtime in FluentAPI PR #133
- Add events and the ability deserialize events properly from a docker host. It also supports events not yet typed and thus ability to manage events that is new but not yet incorporated into FluentDocker. (Events Round 1) PR #134
- Ability to set --dns on a container via fluent api Issue #122
- @MindaugasLaganeckas New feature: WaitForMessageInLogs PR #120
- Externalize rendering of DockerFile Issue #108
- @MindaugasLaganeckas Added Feature: waitForHealthy PR #118
Bug FIxes:
- Fixed so resolver is always created - no matter what Issue #165
- @gitfool Fixed NetworkExtensions.ToHostPort returns wrong host endpoint PR #159
- Better exception handling / throwing when each docker binary is not present
- Hosts.Discover is much more error resilient
- @truepele Fixed NetworkLs: Fix parsing of CreatedAt PR #144
- [Fix] Liner ordering needs to be strict in FileBuilder. PR #119
- @MindaugasLaganeckas Fixes copyTo/copyFrom with throwOnError: true PR #117