# Compose v2 - Monetix Gateway

x-common-env: &common-env
  env_file:
    - ../env/.env.runtime
    - ../env/.env.version

networks:
  sendico-net:
    external: true
    name: sendico-net

services:
  sendico_mntx_gateway:
    <<: *common-env
    container_name: sendico-mntx-gateway
    restart: unless-stopped
    image: ${REGISTRY_URL}/gateway/mntx:${APP_V}
    pull_policy: always
    environment:
      MNTX_GATEWAY_MONGO_HOST: ${MNTX_GATEWAY_MONGO_HOST}
      MNTX_GATEWAY_MONGO_PORT: ${MNTX_GATEWAY_MONGO_PORT}
      MNTX_GATEWAY_MONGO_DATABASE: ${MNTX_GATEWAY_MONGO_DATABASE}
      MNTX_GATEWAY_MONGO_USER: ${MNTX_GATEWAY_MONGO_USER}
      MNTX_GATEWAY_MONGO_PASSWORD: ${MNTX_GATEWAY_MONGO_PASSWORD}
      MNTX_GATEWAY_MONGO_AUTH_SOURCE: ${MNTX_GATEWAY_MONGO_AUTH_SOURCE}
      MNTX_GATEWAY_MONGO_REPLICA_SET: ${MNTX_GATEWAY_MONGO_REPLICA_SET}
      NATS_URL: ${NATS_URL}
      NATS_HOST: ${NATS_HOST}
      NATS_PORT: ${NATS_PORT}
      NATS_USER: ${NATS_USER}
      NATS_PASSWORD: ${NATS_PASSWORD}
      MONETIX_PROJECT_ID: ${MONETIX_PROJECT_ID}
      MONETIX_SECRET_KEY: ${MONETIX_SECRET_KEY}
    command: ["--config.file", "/app/config.yml"]
    ports:
      - "0.0.0.0:${MNTX_GATEWAY_GRPC_PORT:-50075}:50075"
      - "0.0.0.0:${MNTX_GATEWAY_METRICS_PORT:-9405}:9405"
      - "0.0.0.0:${MNTX_GATEWAY_HTTP_PORT:-8084}:8084"
    healthcheck:
      test: ["CMD-SHELL","wget -qO- http://localhost:9405/health | grep -q '\"status\":\"ok\"'"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    networks:
      - sendico-net
