Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build an image running with Nuke gives TarException #618

Closed
lucasteles opened this issue Oct 19, 2022 · 4 comments · Fixed by #630
Closed

Build an image running with Nuke gives TarException #618

lucasteles opened this issue Oct 19, 2022 · 4 comments · Fixed by #630
Assignees
Labels
bug Something isn't working question Have you tried our Slack workspace (https://testcontainers.slack.com)?
Milestone

Comments

@lucasteles
Copy link

Describe the bug
I use Nuke to automate a lot of tasks on my projects, like tests environment configuration, and I did not have any problem running containers with it.
But, when I try to build an image I'm getting:

Unhandled exception. ICSharpCode.SharpZipLib.Tar.TarException: Entry closed at '0' before the '3183' bytes specified in the header were written
      at ICSharpCode.SharpZipLib.Tar.TarOutputStream.CloseEntry()
      at ICSharpCode.SharpZipLib.Tar.TarOutputStream.Finish()
      at ICSharpCode.SharpZipLib.Tar.TarOutputStream.Dispose(Boolean disposing)
      at System.IO.Stream.Close()
      at System.IO.Stream.Dispose()
      at ICSharpCode.SharpZipLib.Tar.TarArchive.Dispose(Boolean disposing)
      at ICSharpCode.SharpZipLib.Tar.TarArchive.Dispose()
      at DotNet.Testcontainers.Images.DockerfileArchive.Tar()
      at DotNet.Testcontainers.Clients.DockerImageOperations.BuildAsync(IImageFromDockerfileConfiguration configuration, CancellationToken ct)
      at Program.<Main>$(String[] args) in C:\d\nuke-testcontainers\src\Program.cs:line 24
      at Program.<Main>(String[] args)

This happens if I run a test, csproj, or even if I put the build logic inside the Nuke Target.

If I run the logic outside Nuke everything works as expected

To Reproduce

Just try to build an image with/from a Nuke target

I made an example to demonstrate the bug:
https://github.com/lucasteles/nuke-testcontainers

If you run on the repository root:

dotnet run --project .\src\

it will work as normal

To get the error run on the repository root :

dotnet tool restore
dotnet nuke

Expected behavior
Should not throw an exception when running from Nuke

@HofmeisterAn
Copy link
Collaborator

HofmeisterAn commented Oct 19, 2022

Is VS running? Exclude the .vs directory via .dockerignore, see (#609):

Or another process is blocking a file. In your case you probably need to exclude the Nuke binaries. I assume they have something similar like Cake's tool directory..

@HofmeisterAn HofmeisterAn added the question Have you tried our Slack workspace (https://testcontainers.slack.com)? label Oct 19, 2022
@HofmeisterAn
Copy link
Collaborator

The .NET implementations use Glob pattern matching, it looks like there are more cases covered by Docker or Go. As far as I know, * will match everything except slashes. Files in .nuke/ are not ignored e.g.

Try the following:

**
!src
src/obj
src/bin

OC, * should behave the same like in Docker.

@HofmeisterAn HofmeisterAn added the bug Something isn't working label Oct 20, 2022
@lucasteles
Copy link
Author

@HofmeisterAn changing the glob to ** worked 🎉

@HofmeisterAn
Copy link
Collaborator

👍 I will reopen it. It makes sense to support * too (same behavior as Docker). Other developers may stumble across the same issue. We can map a single * to ** internal, that would fix the issue without much effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Have you tried our Slack workspace (https://testcontainers.slack.com)?
Projects
None yet
2 participants