defang icon indicating copy to clipboard operation
defang copied to clipboard

Should be able to use redis as a hostname

Open raphaeltm opened this issue 1 year ago • 3 comments

This fails:

services:
  api:
    restart: always
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - mode: ingress
        target: 3000
        published: 3000
    environment:
      - REDIS_HOST=redis
      - REDIS_PORT=6379
  
  processor:
    restart: always
    build:
      context: .
      dockerfile: Dockerfile
    deploy:
      replicas: 2
    environment:
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - PROCESSOR=true

  redis:
    image: redis:alpine
    x-defang-redis: true
    ports:
      - 6379:6379

I looked back through the BullMQ Sample and realized I probably need to change redis to redisx to make it work, but this is something I'm certain other people will run into that needs to be fixed.

raphaeltm avatar Jul 17 '24 21:07 raphaeltm

After a chat with @edwardrf he reminded me that it's not that redis as a hostname is a problem, it's that it would replace any instance of a matching string in an env var. So it caused a problem with the bullmq sample where I had a connection string: redis://redis:6379

So I'm unsure why the compose file above failed. I'll need to keep digging.

raphaeltm avatar Jul 18 '24 20:07 raphaeltm

The right fix is to deploy an instance of CoreDNS in our Playground cluster and do DNS lookups per tenant, instead of using a shared Route53 private zone. Then we no longer need this replacement hack.

lionello avatar Jul 29 '24 18:07 lionello

Need to investigate the alternative of running (private) services on ECS-EC2 so we can override the DNS search domain in /etc/resolv.conf.

lionello avatar Sep 26 '24 21:09 lionello