Skip to content
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

PR Proposal: Expose maven properties to the execution of wait configurations. #1111

Closed
blaxx opened this issue Oct 11, 2018 · 1 comment
Closed

Comments

@blaxx
Copy link

blaxx commented Oct 11, 2018

Info

  • d-m-p version : 0.27.2
  • Maven version : Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)
  • Docker version : Version 18.06.1-ce-mac73 (26764)

Use Case

We are using Jenkins in a docker container to run builds and integration tests. The test server we run the integration tests against is a docker container as well. In order to avoid a docker-in-docker situation, the daemon socket is exposed to the jenkins container via -v /var/run/docker.sock:/var/run/docker.sock, which results in the two containers being siblings rather than parent and child. As such, they share the same network (bridge), which also means ´localhost´ from within the jenkins container points to the jenkins container and not the docker host. It would be great if we could use the IP assigned to the container to ping for readiness (and to deploy integration tests eventually).

Problem

Given the following image configuration for the test server:

<image>
  <alias>aem</alias>
  <name>aem/aem-author:latest</name>
  <run>
    <ports>
      <port>4502:4502</port>
    </ports>
    <wait>
      <http>
        <url>http://${docker.container.aem.ip}:4502/bin/aemready</url>
        <status>200</status>
      </http>
      <time>60000</time>
    </wait>
  </run>
</image>

This results in an IllegalArgumentException Illegal character in authority at index 7: http://${docker.container.aem.ip}:4502/bin/aemready when trying to construct the URI for the HttpPingChecker from an url containing a $ character. Indeed, by looking at the code it seems that the wait configuration is executed by the StartContainerExecutor as part of the start routine, at which point the code exposing container properties simply has not run yet.

Proposal

With a small modification to the StartContainerExecutor, the code responsible for exposing the container properties to maven could run as soon as we have successfully obtained a container id. Essentially this means extending the Builder to gain access to the global <exposeContainerProps> as well as moving the exposeContainerProps() method from the Mojo into the StartContainerExecutor.

So what do you think. Does this sound useful to you at all? If so, just let me know, I'd be happy to supply a corresponding pull request.

Cheers guys,
blaxx

@rhuss
Copy link
Collaborator

rhuss commented Oct 12, 2018

Yes, that makes absolute sense. Appreciate any PR which we could integrate to fix this issue.

thanks !

blaxx pushed a commit to blaxx/docker-maven-plugin that referenced this issue Oct 13, 2018
…tartMojo to StartContainerExecution in order to provide container properties to the wait configuration execution.
rohanKanojia pushed a commit to rohanKanojia/docker-maven-plugin that referenced this issue Nov 28, 2018
…tartMojo to StartContainerExecution in order to provide container properties to the wait configuration execution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants