Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.
MIT License
217
stars
32
forks
source link
Files with --pre-archive are only copied if there are Volumes/Bind Mounts #89
First of all thank you for this great project. It works amazingly well.
Summary
Current behaviour: Using the --pre-archive flag only copies files if there are volumes configured.
Expected behaviour: Using the --pre-archive flag always copies files, if there are files available.
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:
Use the --pre-archive flag and replace the helper functions with your own manual withFileSystemBind calls: This is not nice because you will have to do all the work of the upstream helper functions manually. See also https://github.com/joyrex2001/kubedock/issues/53.
Do not use the --pre-archive flag and therefore kubedock will copy the files after the container has already started and therefore you need to wait for the files to be copied using a custom command/entrypoint (See also https://github.com/joyrex2001/kubedock/issues/53).
Use the --pre-archive flag and a manual existing bind mount as shown below as a current work around
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
)
)
)
...
First of all thank you for this great project. It works amazingly well.
Summary
--pre-archive
flag only copies files if there are volumes configured.--pre-archive
flag always copies files, if there are files available.Context
The
withFileSystemBind
got deprecated and replaced withwithCopyToContainer
. As a result, most testcontainer module providers will therefore switch to usingwithCopyToContainer
somewhere deep down in their file config helper methods, e.g.: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:withFileSystemBind
calls: This is not nice because you will have to do all the work of the upstream helper functions manually. See also https://github.com/joyrex2001/kubedock/issues/53.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.: