supercharge / mongodb-github-action

Use MongoDB in GitHub Actions
MIT License
222 stars 46 forks source link

Connection refused #14

Closed enyo closed 3 years ago

enyo commented 3 years ago

I'm running my tests in a docker container. So connecting to the mongodb container doesn't work. Do you know of a way to make these two containers communicate with each other? Do I need docker compose for that?

marcuspoehls commented 3 years ago

@enyo Hey Matias, are you running your tests locally on your machine? What operating system are you using? Windows?

enyo commented 3 years ago

Hey, I tried running them on GitHub actions first, and then started working on running them locally, but realised that the problem was, that I'm starting two docker containers that need to interact with one another.

enyo commented 3 years ago

To explain it a bit better: I want to run my tests in the google/dart docker container. So I have:

container:
  image: google/dart:latest

in my workflow yaml file.

This causes my steps to run inside a docker container themselves instead of the virtual machine directly. Since my steps are now inside a docker container themselves, they can't connect to localhost:27017 anymore.

marcuspoehls commented 3 years ago

@enyo Ah, now I understand your setup. What I’m thinking of is GitHub Actions Services.

Here’s a short description from the docs:

Used to host service containers for a job in a workflow. Service containers are useful for creating databases or cache services like Redis. The runner automatically creates a Docker network and manages the life cycle of the service containers.

I guess the Docker network part is important to have all services and apps connect to each other.

Did you already try services?

enyo commented 3 years ago

Hi! Thanks, that was exactly what I was looking for.

marcuspoehls commented 3 years ago

@enyo Sweet! Good to hear you found a solution 👍