services:
  postgres:
    command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=bWUz5384u06K54zG6B8L
      - POSTGRES_DB=nakama
    expose:
      - "8080"
      - "5432"
    image: postgres:12.2-alpine
    ports:
      - "5432:5432"
      - "8080:8080"
    volumes:
      - data:/var/lib/postgresql/data

  nodejs:
    build:
      context: ./cardano-message-signing-demo
      dockerfile: backend/Dockerfile
    ports:
      - "8081:8081"
    volumes:
      - ./cardano-message-signing-demo:/app
    restart: unless-stopped

  nakama:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - postgres
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address postgres:bWUz5384u06K54zG6B8L@postgres:5432/nakama &&
        exec /nakama/nakama --config /nakama/data/local.yml --database.address postgres:bWUz5384u06K54zG6B8L@postgres:5432/nakama
    expose:
      - "7349"
      - "7350"
      - "7351"
    healthcheck:
      test: ["CMD", "/nakama/nakama", "healthcheck"]
      interval: 10s
      timeout: 5s
      retries: 5
    links:
      - "postgres:db"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    restart: unless-stopped

volumes:
  data: