version: "3"

networks:
  global:
    external: true

services:
  nginx_proxy:
    image: registry.gitlab.com/skinholdings/drakemall-frontend/nginx-proxy:stable
    deploy:
      labels:
        - traefik.port=80
        - traefik.docker.network=global
        - traefik.frontend.rule=Host:${BRANCH_NAME-develop}.drakemall.xyz
        - traefik.backend.loadbalancer.stickiness=true
      resources:
        limits:
          memory: 1024M
    environment:
      NAMESERVERS: "127.0.0.11"
      PORT: 80
      DOMAIN_NAME: drakemall.com
      # Internal url that points to public accessible address used by service.prerender.io
      WEB_SERVICE_URL: nginx_proxy:80
      API_GATEWAY_SERVER: drakemall:5000
      PRERENDER_HOST: prerender:3000
      SITEMAP_SERVER: "sitemap:8090"
      PRERENDER_TOKEN: ""
      COUNTY_BLACKLIST: "SK|MT"
      # PRERENDER_HOST: service.prerender.io
    ports:
    - 80:80
    networks:
    - global
    depends_on: 
    - drakemall
    - sitemap

  drakemall:
    image: registry.gitlab.com/skinholdings/drakemall:stable
    deploy:
      labels:
        - traefik.port=5000
        - traefik.docker.network=global
        - traefik.frontend.rule=Host:${DOMAIN_NAME:-local.drakemall.com}
        - traefik.backend.loadbalancer.stickiness=true
      resources:
        limits:
          memory: 1024M
        reservations:
          memory: 512M
    environment:
      DEBUG: "socket.io-redis,engine:socket"
      PORT: 5000
      PAYMENT_GATEWAY_ENABLE: 'yes'
      DOMAIN_NAME: dev.drakemall.com
      VAULT_ENABLE: 'yes'
      VAULT_CONFIG_KEYS: 'test,development'
      REDIS_URL: redis://redis:6379/0
      VAULT_ADDR: https://vault.drakemall.xyz
      VAULT_TOKEN: ${VAULT_TOKEN}
    ports:
    - 5000:5000
    labels: 
      kompose.service.type: loadbalancer
      # kompose.service.expose: "true"
    healthcheck:
      test:
        - CMD
        - curl 
        - -f
        - http://localhost:5000
      interval: 20s
      timeout: 10s
      retries: 2

    networks:
      - global
  
  sitemap:
    image: skinholdings/drakemall-sitemap:latest
    environment:
      PORT: "8090"
      SITEMAP_HOSTNAME: "https://dev.drakemall.com"
      DRAKEMALL_API_ADDR: "https://dev.drakemall.com"
    deploy:
      resources:
        limits:
          memory: 128M
          cpus: '0.2'
        reservations:
          cpus: '0.1'
          memory: 64M
    healthcheck:
      test:
        - CMD
        - curl 
        - -f
        - http://127.0.0.1:8090/health
      interval: 10s
      timeout: 5s
      retries: 2
    ports:
      - 8090
    networks:
      - global
