You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use withCopyFilesToContainer to copy files onto a container. The build system I am using is Bazel, which runs the javascript inside a sandbox. The sandbox contains only symlinks to the actual files that need to be copied and so I need a way for testcontainers to follow the symlink and copy the linked file instead of the link itself.
My workaround currently is to read the file and then use withCopyContentToContainer instead.
This would be simpler if the tar we copy to the container follows symlinks by default. With tar we can use -h, -H or -L for this behaviour:
-L, --dereference
(c and r modes only) All symbolic links will be followed. Normally, symbolic links are archived as such. With this option, the target of the link will be archived instead.
Expected Behaviour withCopyFilesToContainer should follow symlinks referenced by source when copying files into the container so that the copied file can be read rather than remaining a link to the linked file.
Actual Behaviour withCopyFilesToContainer puts the file at the right target, but if it is a symlink it remains a symlink rather than following the link and copying the linked file.
Testcontainer Logs
2024-02-03T00:12:12.808Z testcontainers [DEBUG] Creating container for image "ghcr.io/apollographql/router:v1.38.0"...
2024-02-03T00:12:12.886Z testcontainers [DEBUG] [d792c2d98366] Created container for image "ghcr.io/apollographql/router:v1.38.0"
2024-02-03T00:12:12.888Z testcontainers [DEBUG] [d792c2d98366] Putting archive to container...
2024-02-03T00:12:12.912Z testcontainers [DEBUG] [d792c2d98366] Put archive to container
2024-02-03T00:12:12.912Z testcontainers [INFO] [d792c2d98366] Starting container for image "ghcr.io/apollographql/router:v1.38.0"...
2024-02-03T00:12:12.912Z testcontainers [DEBUG] [d792c2d98366] Starting container...
2024-02-03T00:12:13.143Z testcontainers [DEBUG] [d792c2d98366] Started container
2024-02-03T00:12:13.143Z testcontainers [INFO] [d792c2d98366] Started container for image "ghcr.io/apollographql/router:v1.38.0"
2024-02-03T00:12:13.143Z testcontainers [DEBUG] [d792c2d98366] Inspecting container...
2024-02-03T00:12:13.322Z testcontainers [DEBUG] [d792c2d98366] Inspected container
2024-02-03T00:12:13.322Z testcontainers [DEBUG] [d792c2d98366] Fetching container logs...
2024-02-03T00:12:13.331Z testcontainers [DEBUG] [d792c2d98366] Demuxing stream...
2024-02-03T00:12:13.331Z testcontainers [DEBUG] [d792c2d98366] Demuxed stream
2024-02-03T00:12:13.331Z testcontainers [DEBUG] [d792c2d98366] Fetched container logs
2024-02-03T00:12:13.331Z testcontainers [DEBUG] [d792c2d98366] Waiting for container to be ready...
2024-02-03T00:12:13.331Z testcontainers [DEBUG] [d792c2d98366] Host port wait strategy complete
2024-02-03T00:12:13.331Z testcontainers [INFO] [d792c2d98366] Container is ready
2024-02-03T00:12:13.331Z testcontainers:containers [d792c2d98366] total 16
2024-02-03T00:12:13.331Z testcontainers:containers [d792c2d98366] drwxr-xr-x 1 root root 4096 Feb 3 00:12 .
2024-02-03T00:12:13.331Z testcontainers:containers [d792c2d98366] drwxr-xr-x 1 root root 4096 Jan 19 20:47 ..
2024-02-03T00:12:13.331Z testcontainers:containers [d792c2d98366] lrwxrwxrwx 1 root root 71 Feb 2 22:45 local.graphql -> ../../../../../../../../../infra/local/router/schema/supergraph.graphql
Steps to Reproduce
With a source that is a symlink.
Copy symlink to a target on the container.
See that the copied file is still a symlink, rather than a real file with the contents of the original.
Hi @jackvincentnz, thanks for raising. The archiving library we use is node-archiver, I've read through their docs and dereferencing is not supported. It only supports copying in symlinks, but without the source file the contents is lost. I'd happily accept a PR which swaps this library with another that supports this functionality
Summary
I am trying to use
withCopyFilesToContainer
to copy files onto a container. The build system I am using is Bazel, which runs the javascript inside a sandbox. The sandbox contains only symlinks to the actual files that need to be copied and so I need a way for testcontainers to follow the symlink and copy the linked file instead of the link itself.My workaround currently is to read the file and then use
withCopyContentToContainer
instead.E.g.
This would be simpler if the tar we copy to the container follows symlinks by default. With
tar
we can use-h
,-H
or-L
for this behaviour:Expected Behaviour
withCopyFilesToContainer
should follow symlinks referenced bysource
when copying files into the container so that the copied file can be read rather than remaining a link to the linked file.Actual Behaviour
withCopyFilesToContainer
puts the file at the right target, but if it is a symlink it remains a symlink rather than following the link and copying the linked file.Testcontainer Logs
Steps to Reproduce
E.g.
Environment Information
Mac
Docker version 24.0.7, build afdd53b
18
10.6.0
The text was updated successfully, but these errors were encountered: