MongoDB docker container, unable to connect anymore

Hello all.

Until two weeks ago, my CI/CD using github actions and docker containers worked perfectly.

But now, the CI/CD fails everytime because I am not able to connect to the MongoDB container anymore and run my integration tests. I did not change anything in my config files (neither docker-compose.yml, neither Dockerfile, neither the workflow yml file and neither the init-mongo.js file).

Here is my workflow :

jobs:
  build:
    runs-on: ubuntu-18.04

    steps:
    - uses: actions/checkout@v2
    - name: Build the Docker containers
      run: docker-compose -f docker-compose.test.yml up  -d
    - name: Check docker containers status
      run: docker ps
    - name: Create database
      run: docker-compose exec -T -u root php bin/console d:m:s:c --env=test

Here is the content of the docker-compose.test.yml file :

version: '3.7'
services:
  appquarium-mongo-apiuser:
    image: mongo
    container_name: appquarium-mongo-apiuser
    environment:
      MONGO_INITDB_DATABASE: database_name
      MONGO_INITDB_ROOT_USERNAME: username
      MONGO_INITDB_ROOT_PASSWORD: password
    volumes:
      - .docker/mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
    ports:
      - 27017:27017

  appquarium-php-apiuser:
    image: deozza/appquarium-apiuser
    build:
      context: .
      dockerfile: .docker/php/Dockerfile
      target: test
    container_name: appquarium-php-apiuser
    restart: on-failure
    user: '1000:1000'

And here is the error I got since two days :
No suitable servers found (serverSelectionTryOnceset): [connection refused calling ismaster on 'appquarium-mongo-apiuser:27017']

Needless to say that when I replicate the workflow manually on my dev environment, and even on my prod environment, all works perfectly.

Any idea ? Does your workflow still working ? Has something changed within the github action system that I missed and I need to adapt to ?

Hi @deozza,

Glad to see you in Github Community Forum!

AFAIK there’s no update related, if you didn’t change anything, could you please rerun the successful workflow (2 weeks ago?) and check the result?

If it’s still successful, please compare the differences for debug.
If it’s failed as well, please check if there’re any secrets used and update the value for a try.

If the issue persists, it’s recommended to share the repo/sample repo for further investigation.

Thanks.

Hi @weide-zhou and thank you for the reply.

I will try to backtrack to a previously successful workflow and keep you post about it. There’s no secrets used for the db connection (only for docker repo connection and they work well).

Now, I use a remote mongodb server to launch the tests inside the workflow and it passed. It is not an optimal solution (because of the time it takes to rebuild between tests) , but it lets me going on with my CD.

I will post a sample repo later today to help you investigate

Hi @deozza,

Thanks for your reply! How’s it go? Is it resolved?

I just achieved a successful backtrack yesterday. The only thing that changed between the failed workflow and the successful one, was the timing of the composer install.

In the working workflow, I use composer install in the github workflow. In the failed ones, I use composer install in the docker image build.

The thing now, is to know why it has an impact in Github Actions, and why it’s not impacting my CI in local