services:
  cart:
    build:
      context: .
      dockerfile: cart/Dockerfile
    ports:
      - "8080:8080"
    depends_on:
      - product-service

  product-service:
    image: gitlab-registry.ozon.dev/go/classroom-18/students/homework-draft/products:latest
    ports:
      - "8082:8082"

  loms:
    build: 
      context: .
      dockerfile: loms/Dockerfile
    depends_on:
      - postgres-master
    ports:
      - "8083:8083"
      - "8084:8084"
      - "8085:8085"

  postgres-master:
    image: gitlab-registry.ozon.dev/go/classroom-18/students/base/postgres:16
    container_name: postgres-master
    environment:
      - POSTGRESQL_USERNAME=user
      - POSTGRESQL_PASSWORD=password
      - POSTGRESQL_DATABASE=route256
      - POSTGRESQL_REPLICATION_MODE=master
      - POSTGRESQL_REPLICATION_USER=repl_user
      - POSTGRESQL_REPLICATION_PASSWORD=repl_password
      - POSTGRESQL_SYNCHRONOUS_COMMIT_MODE=on
      - POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS=1
    ports:
      - "5433:5432"

  postgres-replica:
    image: gitlab-registry.ozon.dev/go/classroom-18/students/base/postgres:16
    container_name: postgres-replica
    depends_on:
      - postgres-master
    environment:
      - POSTGRESQL_DATABASE=route256
      - POSTGRESQL_USERNAME=user
      - POSTGRESQL_PASSWORD=password
      - POSTGRESQL_REPLICATION_MODE=slave
      - POSTGRESQL_REPLICATION_USER=repl_user
      - POSTGRESQL_REPLICATION_PASSWORD=repl_password
      - POSTGRESQL_MASTER_HOST=postgres-master
      - POSTGRESQL_MASTER_PORT_NUMBER=5432
      - POSTGRESQL_SYNCHRONOUS_COMMIT_MODE=on
      - POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS=1
    ports:
      - "5434:5432"
