V
V
Vocler2019-07-08 23:00:47
Software design
Vocler, 2019-07-08 23:00:47

How to write docker-compose.yml with db for tests?

There is a dockerized project, docker-compose.yml looks like this:

version: '3'
services:
  web:
    /*Основное приложение*/
  db:
    /*База данных*/
  phpmyadmin:
    /*PHPMyAdmin*/
    ports:
      - 8080:80
    depends_on:
      - db

I want to cover the project with tests. As I understand it, the tests need their own database. Here I see 2 options:
1) The most obvious: Create two new services: test_db and, accordingly, phpmyadmin for it
test_db:
      /*База данных*/
  test_phpmyadmin:
    /*PHPMyAdmin*/
    ports:
      - 8080:80
    depends_on:
      - test_db

Isn't it bold to single out two services specifically for tests? Or is it considered normal?
2) On the same old db service, create a second database. But here the problem is that there is no normal way to do this through the enviroment, and you will have to come up with crutches with the entrypoint. For example: https://forums.docker.com/t/multiple-databases-in-...
What would be the best approach in this situation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question