services:
  mongo:
    container_name: mongo
    image: mongo:6
    # Tests open and close many connections to mongoDB in a short span of time, making it open many file descriptors at once.
    # Some tests might fail without expanding the amount of file descriptors mongo can have open
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    ports:
    - 27017:27017
    volumes:
    - datadb:/data/db
    restart: unless-stopped

  registry:
    container_name: registry
    image: registry:2
    ports:
    - 5000:5000
    volumes:
    - /var/lib/registry
    restart: unless-stopped

  deploy-agent:
    container_name: deploy-agent
    image: tsuru/deploy-agent:v2.10.0
    environment:
    - BUILDKIT_DETECT_CPU_ARCH=true
    command:
    - -port=8000
    - -buildkit-addr=tcp://buildkit:8001
    ports:
    - 8000:8000
    restart: unless-stopped
    depends_on:
    - registry
    - buildkit

  buildkit:
    container_name: buildkit
    image: moby/buildkit:v0.12.1
    privileged: true
    volumes:
    - ./etc/buildkitd.toml:/etc/buildkit/buildkitd.toml
    restart: unless-stopped
    depends_on:
    - registry

  tsuru-api:
    container_name: tsuru-api
    build: ./
    image: tsuru/api:edge
    ports:
    - 8080:8080
    volumes:
    - ./etc/tsurud.conf:/etc/tsuru/tsuru.conf:ro
    restart: unless-stopped
    depends_on:
    - mongo
    - deploy-agent
    profiles:
    - tsurud-api

volumes:
  datadb: