version: '3'

volumes:
  persistent-data:

services:
  rove-accountant:
    build:
      context: .
      dockerfile: Dockerfile
    image: rove:latest
    ports:
      - "9091:9091"
    environment:
      - PORT=9091
      - DATA_PATH=/mnt/rove-server
    volumes:
      - persistent-data:/mnt/rove-server:rw
    command: [ ./rove-accountant ]

  rove-docs:
    build:
      context: .
      dockerfile: Dockerfile.docs
    image: rove-docs:latest
    ports:
      - "80:80"
    environment: 
      - PORT=80

  rove-server:
    depends_on: [ rove-accountant ]
    build:
      context: .
      dockerfile: Dockerfile
    image: rove:latest
    ports:
      - "9090:9090"
    environment:
      - PORT=9090
      - DATA_PATH=/mnt/rove-server
      - ROVE_ACCOUNTANT_GRPC=rove-accountant:9091
      - WORDS_FILE=data/words_alpha.txt
    volumes:
      - persistent-data:/mnt/rove-server:rw
    command: [ "./script/wait-for-it.sh", "rove-accountant:9091", "--", "./rove-server"]

  rove:
    depends_on: [ rove-server, rove-docs ]
    build:
      context: .
      dockerfile: Dockerfile
    image: rove:latest
    ports:
      - "8080:8080"
    environment:
      - PORT=8080
      - ROVE_GRPC=rove-server:9090
    command: [ "./script/wait-for-it.sh", "rove-server:9090", "--", "./rove-reverse-proxy" ]

  rove-tests:
    depends_on: [ rove ]
    build:
      context: .
      dockerfile: Dockerfile
    image: rove:latest
    environment:
      - ROVE_ACCOUNTANT_GRPC=rove-accountant:9091
      - ROVE_HTTP=rove
      - ROVE_GRPC=rove-server
    command: [ "./script/wait-for-it.sh", "rove:8080", "--", "go", "test", "-v", "./...", "--tags=integration", "-cover", "-coverprofile=/mnt/coverage-data/c.out", "-count", "1" ]
    volumes:
      - /tmp/coverage-data:/mnt/coverage-data:rw


  
