-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Cannot access local network services from the PHPUnit container #28
Comments
I figured that So I created PR #29 implementing this change. |
Very interesting, thanks. I see your Skosmos repo is ready and waiting for this issue to be resolved, so I'll test the PR as soon as I can. Hopefully we can get this merged in later today. |
Released! Please see v3. Cheers. |
This is probably the same issue as #26 but I'm not 100% sure so I'm opening a separate issue.
I'm trying to set up the test suite for my application (Skosmos) which needs to access a Jena Fuseki triple store (RDF database). I've set it up as a service container, just like @shamotj has done with PostgreSQL. But I can't access it from the PHPUnit tests if I use php-actions/phpunit. The reason seems to be that the container where the PHPUnit tests are executed is not in the same (virtual) network as the service container. The service container I use is configured like this:
and the command that starts it up (automatically generated by the GitHub Actions environment) looks like this:
The important parameter here is
--network github_network_b6654ecefeeb43dba0ad25d5aad81a77
, which specifies a network for the service container. In addition,--network-alias fuseki
creates a name that refers to this container, so it now becomes accessible as the hostnamefuseki
from other containers attached to the same network.But the command for starting the PHPUnit container looks like this:
Note that there is no
--network
parameter, so this container will be attached to the default bridge network, not the specific network where the Fuseki service container is. So it is in effect isolated from the rest of the system and cannot access any network services in the same CI environment. Consequently, my PHPUnit tests are failing with this error:I think that the fix would be to add a
--network
parameter to thedocker run
command with the correct network ID; in my example, it wasgithub_network_b6654ecefeeb43dba0ad25d5aad81a77
. Unfortunately I'm not sure how to construct this network ID; it doesn't appear among the default environment variables set by GitHub Actions but it's possible that it could be constructed based on them.Alternatively, the parameter could be set to
--network host
and then the PHPUnit container would not be in its own isolated network. Then the service containers could be exported to the host using the normalports
mapping mechanism and they should be accessible to the PHPUnit tests.The text was updated successfully, but these errors were encountered: