Closed osma closed 3 years ago
I figured that --network host
is the best choice here because it allows accessing services both on the runner machine (host) and in service containers. The alternative, using something like --network github_network_b6654ecefeeb43dba0ad25d5aad81a77
would be more difficult to implement (how to construct the network ID?) and then the container would only be able to access service containers, but not any services running on the host machine.
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.