Test between multiple repositories

,

Hello,
I am doing a project that has multiple APIs (php) as if they were microservices.

I did an integration test of each API and now I did an integration test crossing the APIs, it works perfectly for me locally, but now I want to take it to the CI/CD to be able to test and deploy.

The project has the following repository structure

  • Database
  • memcached
  • Traefik
  • API 1
  • API 2

I have a self-hosted gitlab

I am trying to mount it with Docker dind, I have managed to make the dind work but for example when the test is repeated what is created inside the Dind is still there and therefore the CI gives me an error, I cannot expose the ports to be able to do the requests between the different dockers.

This is my gitlab-ci.yml

stages:
  - preparation

variables:
  # Create the certificates inside this directory for both the server
  # and client. The certificates used by the client will be created in
  # /certs/client so we only need to share this directory with the
  # volume mount in config.toml.
  DOCKER_TLS_CERTDIR: "/certs"


composer:
  stage: preparation
  services:
    - docker:19.03.12-dind
  image: docker/compose
  before_script:
    - docker info
    - echo "127.0.0.1  cms.domain.local files.domain.local" >> /etc/hosts
    - apk update
    - apk add openssh-client git
    - docker ps
    - docker network create web
    - docker network create domain
    - docker network create domain-web
    - docker network create domain-files
    - cd ..
    - |
      if [ -d "traefik" ]; then
        cd traefik && git pull https://oauth2:$CLONE_KEY@gitlab.domain.com/domain/microservicios/traefik.git
      else
        git clone https://oauth2:$CLONE_KEY@gitlab.domain.com/domain/microservicios/traefik.git && cd traefik
      fi
    - docker-compose up -d
  script:
   - docker-compose --version
   - cat /etc/hosts
   - pwd
   - ls

Thanks for the help.