DefangLabs / defang

Defang CLI and sample projects. Defang is a radically simpler way for developers to develop, deploy, and debug cloud applications.
https://defang.io
MIT License
29 stars 6 forks source link

Should be able to use redis as a hostname #547

Open raphaeltm opened 2 months ago

raphaeltm commented 2 months ago

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 commented 2 months ago

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.

lionello commented 2 months ago

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 commented 1 day ago

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