tox-docker icon indicating copy to clipboard operation
tox-docker copied to clipboard

[feature] Ability to reference a docker-compose.yml file from the tox config

Open AlanCoding opened this issue 1 year ago • 0 comments

You have a way to reference a Dockerfile which already exists in someone's project:

[docker:app]
dockerfile = {toxinidir}/Dockerfile

I define the service details inside of my docker-compose.yml file. See https://github.com/ansible/django-ansible-base/pull/632, and associated project, copying from the docker-compose.yml here:

---
services:
  postgres:
    image: "postgres:15"
    container_name: dab_postgres
    environment:
      POSTGRES_DB: dab_db
      POSTGRES_USER: dab
      POSTGRES_PASSWORD: dabing
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "dab", "-d", "dab_db"]
      interval: 10s
      timeout: 5s
      retries: 5
    ports:
      - "55432:5432"

What I would like to do is to say "use the details from the postgres service in file xyz". That would require a reference to the docker-compose.yml file (similar to your example with Dockerfile), and the name of the service. Spitball of this:

[docker:db]
compose_file = {toxinidir}/docker-compose.yml
service = postgres

This way, I wouldn't have to maintain a separate set of parameters. For instance, my tests are going to (at some level) hard-code the database username and password. I don't want to define the postgres username/password in docker-compose.yml for manual testing, and then also in tox.ini for CI. I'd rather have just 1 source of truth.

This does not appear to be possible right now, so filing as a feature request.

AlanCoding avatar Oct 30 '24 13:10 AlanCoding