From d4a1e71ec65aa272532ad285afdf263312096e6d Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:52:21 +0100 Subject: [PATCH] fix(#610): Trim traling slashes in Dockerfile directory path (otherwise, it cuts the first character of the relative path) --- CHANGELOG.md | 4 ++++ src/Testcontainers/Images/DockerfileArchive.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5071c58d8..4e75c6469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - 642 Expose container port bindings automatically +### Fixed + +- 610 Trim traling slashes in Dockerfile directory path (otherwise, it cuts the first character of the relative path) + ## [2.2.0] ### Added diff --git a/src/Testcontainers/Images/DockerfileArchive.cs b/src/Testcontainers/Images/DockerfileArchive.cs index e4ebc7d70..bcb82085d 100644 --- a/src/Testcontainers/Images/DockerfileArchive.cs +++ b/src/Testcontainers/Images/DockerfileArchive.cs @@ -77,7 +77,7 @@ public string Tar() foreach (var file in GetFiles(this.dockerfileDirectory.FullName)) { // SharpZipLib drops the root path: https://github.com/icsharpcode/SharpZipLib/pull/582. - var relativePath = file.Substring(this.dockerfileDirectory.FullName.Length + 1); + var relativePath = file.Substring(this.dockerfileDirectory.FullName.TrimEnd('/', '\\').Length + 1); if (dockerIgnoreFile.Denies(relativePath)) {