arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
120 stars 98 forks source link

Automatic Resolution of Docker elements #597

Closed lordofthejars closed 7 years ago

lordofthejars commented 7 years ago
Issue Overview

Automatic Resolution of Docker files like docker-compose or Dockerfile

Expected Behaviour

If user does not set dockerContainers nor dockerContainersFile/s then it would be great that Arquillian Cube does next things:

1) search in /docker-compose.y(a)ml if found then it is used 2) if not then search in /src/test/docker/docker-compose.y(a)ml 3) if not /src/test/resources/docker-compose.y(a)ml 4) if not /src/test/resources/docker/docker-compose.y(a)ml

if it is not present in any of these locations search the same but in src/main instead of src/test

If again there is no docker-compose there, just search the same but for Dockerfile, and in case of finding it, get the EXPOSE port/s and create dynamically a dockerContainers expression building that container

If none of this things happens then an exception is thrown.

In this way we avoid having to create an arquillian.xml file all the time.

dipak-pawar commented 7 years ago

@lordofthejars Idea looks good. But I would look for following locations.

  1. project's current dir.
  2. test resources dir -> recursively look for docker-compose.yml OR Dockerfile in all directories inside test resources.
  3. main resources -> recursively look for docker-compose.yml OR Dockerfile in all directories inside test resources.

In this way we are not forcing user to put docker file inside test/resources/docker/Dockerfile.

User can put Dockerfile in any folder under resources.

lordofthejars commented 7 years ago

@dipak-pawar I agree with you, the problem is that I have seen some people putting these files in src/main/docker which it is not a resources dir. SO we can do what you mention + src/main(test)/docker

dipak-pawar commented 7 years ago

@lordofthejars I would assume priority for src/main(test)/docker as last.

lordofthejars commented 7 years ago

Easy: https://twitter.com/alexsotob/status/834649977599193088

bartoszmajsak commented 7 years ago

From my point of view we should look it up in the following way:

  1. Project root folder
  2. src/{main,test}/docker
  3. src/{main,test}/resources

I doubt we will have files in more than one place listed above, but you never know, so in such a case I would report and suggest configuration (still taking precedence as a default).

MatousJobanek commented 7 years ago

Well, from my point of view the directory src/{main,test}/docker is definitely not the correct place where you should keep our test resources. For this purpose, there is the resources directory and I would really avoid creating this new "dummy" directory for docker related things and I would keep the convention. In addition, the files are not connected to the java project anyhow - they're just another resource files.

I would vote for this order:

  1. src/test/resources
  2. src/main/resources
  3. root project
  4. then we could consider some docker directory either in src/{main,test}/ or in the root project
bartoszmajsak commented 7 years ago

@MatousJobanek I saw it used quite a lot to be honest. Therefore if we find such a directory user does it by purpose. That's why my suggested order.

resources is too generic, so I can undrestand why people tend to have dedicated folder for docker images.

lordofthejars commented 7 years ago

Also adding in src/main/resources means that goes inside JAR. What I have seen in a lot of places is the src/main/docker as well.

MatousJobanek commented 7 years ago

I saw it used quite a lot to be honest.

Ok, I don't have the experience so I cannot judge.

resources is too generic, so I can undrestand why people tend to have dedicated folder for docker images.

yeah, in this case, I would expect a docker directory inside of the resources directory

For me the path src/main/docker looks just weird, but it is probably because I don't have enough experience with it...

bartoszmajsak commented 7 years ago

We are not trying to promote anything, just handle locations where ppl put it.

lordofthejars commented 7 years ago

@MatousJobanek neither do I I have the experience, but I think there is nothing clear in this sense. But for now of 30 votes (64% of people choose src/main/docker)

lordofthejars commented 7 years ago

Final results:

src/main/docker 53% src/main/resources/docker 35% src/main/resources 12%

And then we have other users using / and src/distribution

So my bets are:

1) src/{test, main}/docker (first test if not main) 2) / 3) src/distribution 4) src/{test, main}/resources/docker 5) src/{test, main}/resources

I have left the resources ones to latest because they can be considered somehow a bad practice since the bundling file will contain Dockerfile/docker-compose as well.