joyrex2001 / kubedock

Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.
MIT License
226 stars 33 forks source link

Files with --pre-archive are only copied if there are Volumes/Bind Mounts #89

Closed tricktron closed 5 months ago

tricktron commented 5 months ago

First of all thank you for this great project. It works amazingly well.

Summary

Context

The withFileSystemBind got deprecated and replaced with withCopyToContainer. As a result, most testcontainer module providers will therefore switch to using withCopyToContainer somewhere deep down in their file config helper methods, e.g.:

yourContainer = new ContainerFromModule("someImage")
    .withRamPercentage(75, 75) // some nice helper config function
    .withRealmImportFile("/your-realm.json") // some file helper function which will use `withCopyToContainer` in the end
    ...

These config files must be copied to the container before it is started. It makes therefore sense to use the --pre-archive flag to get these files copied so that we can continue profiting from these useful upstream helper functions because otherwise the alternatives are:

Current Manual Workaround

Just add an existing Bind mount and the --pre-archive flag works as expected and you can continue using the upstream testcontainer module's helper functions, e.g.:

yourContainer = new ContainerFromModule("someImage")
    .withCreateContainerCmdModifier(
         cmd ->
            cmd.getHostConfig()
            .withBinds
            (
                Bind.parse
                (
                    System.getProperty("user.dir") + "/pom.xml:/tmp/pom.xml" // any manual existing bind will do
                )
            )
    )
    ...
joyrex2001 commented 5 months ago

Thanks for the great work 👍