services:
  test:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/app
      # Persist tox environments to speed up subsequent runs
      - tox-cache:/app/.tox
    environment:
      - LANG=en_US.UTF-8
      - LC_ALL=en_US.UTF-8
    # Override command to run bash for interactive use
    # Use: docker compose run --rm test
    # Or run specific tests: docker compose run --rm test sh -c "redis-server --daemonize yes && tox -e py312-django51-pil"
    command: sh -c "redis-server --daemonize yes && tox"

  # Replicate GitHub Actions CI environment
  ci:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/app
      - tox-cache:/app/.tox
    environment:
      - LANG=en_US.UTF-8
      - LC_ALL=en_US.UTF-8
      # Test only the backends used in CI (excludes dynamodb, pgmagick, vipsthumbnail)
      - TARGET=${TARGET:-pil}
      - DJANGO=${DJANGO:-5.1}
    command: sh -c "redis-server --daemonize yes && tox -v"

volumes:
  tox-cache:
