services:
  mysql:
    image: mysql:8.0.22
    command: --default-authentication-plugin=mysql_native_password
    networks:
      - bettersuite-network
    volumes:
      - mysqlvol:/var/lib/mysql
      - ./backup:/var/backup
    environment:
      MYSQL_ROOT_PASSWORD: defaultpassword
    ports:
      - "3306:3306"

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: always
    depends_on:
      - mysql
    networks:
      - bettersuite-network
    environment:
      PMA_HOST: mysql
      MYSQL_ROOT_PASSWORD: defaultpassword
    ports:
      - "8080:80"

  redis:
    image: redis
    networks:
      - bettersuite-network
    volumes:
      - redisvol:/data

  taxi-rider-api:
    image: maehmoed/ridy-rider-api
    restart: always
    depends_on:
      - "mysql"
      - "redis"
      - "taxi-admin-api"
    volumes:
      - ./img:/app/uploads
      - ./config-new:/app/config
    networks:
      - bettersuite-network
    environment:
      - MYSQL_HOST=mysql
      - GATEWAY_SERVER_URL=http://194.60.87.129/payment
      - RIDER_SERVER_URL=http://194.60.87.129/rider-api
      - ENCRYPTION_KEY=lPw3ethAy4WqnWa3b4TAbCUJr89RifEs
      - REDIS_HOST=redis
    ports:
      - "4000:3000"

  taxi-driver-api:
    image: maehmoed/ridy-driver-api
    restart: always
    depends_on:
      - "mysql"
      - "redis"
      - "taxi-admin-api"
    volumes:
      - ./img:/app/uploads
      - ./config-new:/app/config
    networks:
      - bettersuite-network
    environment:
      - MYSQL_HOST=mysql
      - GATEWAY_SERVER_URL=http://194.60.87.129/payment
      - DRIVER_SERVER_URL=http://194.60.87.129/driver-api
      - REDIS_HOST=redis
      - ENCRYPTION_KEY=lPw3ethAy4WqnWa3b4TAbCUJr89RifEs
    ports:
      - "4002:3000"

  taxi-admin-api:
    image: maehmoed/ridy-admin-api
    restart: always
    depends_on:
      - "mysql"
      - "redis"
    networks:
      - bettersuite-network
    volumes:
      - ./img:/app/uploads
      - ./config-new:/app/config
    environment:
      - MYSQL_HOST=mysql
      - REDIS_HOST=redis
    ports:
      - "4001:3000"

  taxi-admin-panel:
    image: maehmoed/ridy-admin-panel
    restart: always
    networks:
      - bettersuite-network
    volumes:
      - taxiassets:/usr/share/nginx/html/assets
    ports:
      - "4003:80"

  payment-gateways:
    image: ridyio/delivery-gateway-box
    depends_on:
      - "taxi-rider-api"
    ports:
      - "3333:3333"
    networks:
      - bettersuite-network
    environment:
      - MYSQL_HOST=mysql
      - TEST_MODE=true
      - MYSQL_DB=ridy
      - GATEWAY_SERVER_URL=http://194.60.87.129/payment
      - ENCRYPTION_KEY=lPw3ethAy4WqnWa3b4TAbCUJr89RifEs

  taxi-rider-web-app:
    image: ridyio/rider-web-app
    restart: always
    networks:
      - bettersuite-network
    ports:
      - "4004:80"
    environment:
      - BASE_URL=http://194.60.87.129/rider-api
      - DEMO_MODE=false

  nginx:
    image: nginx
    depends_on:
      - "payment-gateways"
      - "taxi-rider-api"
      - "taxi-driver-api"
      - "taxi-rider-web-app"
      - "taxi-admin-panel"
      - "taxi-admin-api"

    volumes:
      - ./templates:/etc/nginx/templates
      - ./certbot:/etc/letsencrypt
    ports:
      - "80:80"
      - "443:443"
    environment:
      - NGINX_HOST=_
    networks:
      - bettersuite-network
    # depends_on:
    #   - certbot

    # certbot:
    #   image: certbot/certbot
    #   volumes:
    #     - ./certbot:/etc/letsencrypt
    #   entrypoint: "/bin/sh"
    #   command: "-c 'mkdir -p /etc/letsencrypt/www; trap exit TERM; while :; do certbot certonly --webroot -w /etc/letsencrypt/www --non-interactive --agree-tos --email devops@bettersuite.io -d bettersuite.io && sleep 12h & wait $!; done'"

volumes:
  redisvol:
  mysqlvol:
  taxiassets:


networks:
  bettersuite-network: