-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix problems with copying files and Docker-Compose on Windows #514
Changes from 5 commits
aa9357a
43faf02
029c65d
f4986ae
38a35d1
ae906cb
4b5f861
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sh text eol=lf |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import com.google.common.util.concurrent.Uninterruptibles; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.commons.lang.SystemUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.runner.Description; | ||
import org.rnorth.ducttape.ratelimits.RateLimiter; | ||
import org.rnorth.ducttape.ratelimits.RateLimiterBuilder; | ||
|
@@ -395,6 +396,10 @@ default void validateFileList(List<File> composeFiles) { | |
* Use Docker Compose container. | ||
*/ | ||
class ContainerisedDockerCompose extends GenericContainer<ContainerisedDockerCompose> implements DockerCompose { | ||
|
||
private static final String DOCKER_SOCKET_PATH = "//var/run/docker.sock"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not start with double There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, still works in Linux interestingly ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, on *nix systems, you can use as many $ ls -la /////usr
total 0
drwxr-xr-x@ 10 root wheel 320 Sep 27 08:04 .
drwxr-xr-x 31 root wheel 992 Nov 30 13:02 ..
drwxr-xr-x 976 root wheel 31232 Nov 30 13:02 bin
drwxr-xr-x 263 root wheel 8416 Nov 16 11:38 include
drwxr-xr-x 311 root wheel 9952 Nov 30 13:02 lib
drwxr-xr-x 235 root wheel 7520 Nov 30 13:02 libexec
drwxr-xr-x 15 root wheel 480 Sep 26 22:58 local
drwxr-xr-x 246 root wheel 7872 Nov 30 12:51 sbin
drwxr-xr-x 47 root wheel 1504 Sep 27 08:04 share
drwxr-xr-x 5 root wheel 160 Sep 21 06:32 standalone |
||
public static final char UNIX_PATH_SEPERATOR = ':'; | ||
|
||
public ContainerisedDockerCompose(List<File> composeFiles, String identifier) { | ||
|
||
super(TestcontainersConfiguration.getInstance().getDockerComposeContainerImage()); | ||
|
@@ -405,14 +410,14 @@ public ContainerisedDockerCompose(List<File> composeFiles, String identifier) { | |
// Map the docker compose file into the container | ||
final File dockerComposeBaseFile = composeFiles.get(0); | ||
final String pwd = dockerComposeBaseFile.getAbsoluteFile().getParentFile().getAbsolutePath(); | ||
final String containerPwd = MountableFile.forHostPath(pwd).getResolvedPath(); | ||
final String containerPwd = MountableFile.forHostPath(pwd).getFilesystemPath(); | ||
|
||
final List<String> absoluteDockerComposeFiles = composeFiles.stream() | ||
.map(File::getAbsolutePath) | ||
.map(MountableFile::forHostPath) | ||
.map(MountableFile::getResolvedPath) | ||
.map(MountableFile::getFilesystemPath) | ||
.collect(toList()); | ||
final String composeFileEnvVariableValue = Joiner.on(File.pathSeparator).join(absoluteDockerComposeFiles); | ||
final String composeFileEnvVariableValue = Joiner.on(UNIX_PATH_SEPERATOR).join(absoluteDockerComposeFiles); // we always need the UNIX path separator | ||
logger().debug("Set env COMPOSE_FILE={}", composeFileEnvVariableValue); | ||
addEnv(ENV_COMPOSE_FILE, composeFileEnvVariableValue); | ||
addFileSystemBind(pwd, containerPwd, READ_ONLY); | ||
|
@@ -421,12 +426,19 @@ public ContainerisedDockerCompose(List<File> composeFiles, String identifier) { | |
// as the docker daemon, just mapping the docker control socket is OK. | ||
// As there seems to be a problem with mapping to the /var/run directory in certain environments (e.g. CircleCI) | ||
// we map the socket file outside of /var/run, as just /docker.sock | ||
addFileSystemBind("/var/run/docker.sock", "/docker.sock", READ_WRITE); | ||
addFileSystemBind(getDockerSocketHostPath(), "/docker.sock", READ_WRITE); | ||
addEnv("DOCKER_HOST", "unix:///docker.sock"); | ||
setStartupCheckStrategy(new IndefiniteWaitOneShotStartupCheckStrategy()); | ||
setWorkingDirectory(containerPwd); | ||
} | ||
|
||
@NotNull | ||
private String getDockerSocketHostPath() { | ||
return SystemUtils.IS_OS_WINDOWS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is making an assumption that we are only using docker via their sockets interface. However in Docker Machine setups this may not be available It should be able to use the I just checked |
||
? "/" + DOCKER_SOCKET_PATH | ||
: DOCKER_SOCKET_PATH; | ||
} | ||
|
||
@Override | ||
public void invoke() { | ||
super.start(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not use JB's annotations in our code base. Adds another dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that was not intended, wonder how it got in, thanks for spotting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already using in in multiple places btw.
I don't really care about using it in this place, shall I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lose track of what the best No[nt]Null annotation is 😞
I don't think there's any harm in leaving this here, and if we want to get rid of the JetBrain annotation altogether we could do it everywhere at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it, since I don't think it added anything useful.