Docker deployment on external PostgreSQL/Redis

Hello,

I’m very new to Docker and I’m currently trying to set Redash to use an external PostgreSQL and Redis instead of using the automatically deployed.

Does anyone know how to set it on my Dockerfile ?

You don’t need to modify the Dockerfile actually. Redash gathers these connection strings from environment variables which are defined in docker-compose.yaml. You’ll want to edit this file anyway so you don’t spin-up pointless postgres and redis containers :smiley:

Here’s a sample Dockerfile where I connect to a postgres db running on my local machine:

Note I can’t use localhost here because the docker containers would think this points back into the container, rather than my host. I just changed REDASH_REDIS_URL and REDASH_DATABASE_URL and removed the definitions for postgres and redis services.

Hope that helps.

# This configuration file is for the **development** setup.
# For a production example please refer to getredash/setup repository on GitHub.
version: "2.2"
x-redash-service: &redash-service
  build:
    context: .
    args:
      skip_frontend_build: "true"
  volumes:
    - .:/app
x-redash-environment: &redash-environment
  REDASH_LOG_LEVEL: "INFO"
  REDASH_REDIS_URL: "redis://host.docker.internal:6379/0"
  REDASH_DATABASE_URL: "postgresql://someuser:somepassword@host.docker.internal/postgres"
  REDASH_RATELIMIT_ENABLED: "false"
  REDASH_MAIL_DEFAULT_SENDER: "redash@example.com"
  REDASH_MAIL_SERVER: "email"
  REDASH_ENFORCE_CSRF: "true"
services:
  server:
    <<: *redash-service
    command: dev_server
    depends_on:
      - postgres
      - redis
    ports:
      - "5000:5000"
      - "5678:5678"
    environment:
      <<: *redash-environment
      PYTHONUNBUFFERED: 0
  scheduler:
    <<: *redash-service
    command: dev_scheduler
    depends_on:
      - server
    environment:
      <<: *redash-environment
  worker:
    <<: *redash-service
    command: dev_worker
    depends_on:
      - server
    environment:
      <<: *redash-environment
      PYTHONUNBUFFERED: 0
  email:
    image: djfarrelly/maildev
    ports:
      - "1080:80"
    restart: unless-stopped

Thank you for your response!

Actually, I have to modify the Dockerfile because I’m not using compose.
I have to do it through build and run.
So they only issue I have is to find a way to point my Redash on the Dockerfile to the external PostgreSQL and Redis.

This solution will be deployed on AWS ECS through Pulumi/Terraform.