使用docker部署 redash

2024-02-29 12:26:44 浏览数 (3)

测试需要,需要临时拉起一套redash环境,可以使用下面的docker方式。

具体如下:

1 创建工作目录

代码语言:plaintext复制
mkdir -pv /opt/redash
cd /opt/redash

2 vim .env 内容如下

代码语言:plaintext复制
PYTHONUNBUFFERED=1
REDASH_RATELIMIT_ENABLED='false'
REDASH_LOG_LEVEL=INFO
REDASH_COOKIE_SECRET=secret-secret-secret-create-your-own-by-using-keepass-or-apg-on-lniux 
REDASH_SECRET_KEY=secret-secret-secret-create-your-own-by-using-keepass-or-apg-on-lniux 
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres-or-secret-secret-secret-create-your-own-by-using-keepass-or-apg-on-lniux
APPLICATION_NAME=redash
HOSTING_DOMAIN=domainname.tld 
PROJECT=redash
CERTRESOLVER=letsencrypt

3 vim docker-compose.yml 内容如下

代码语言:yaml复制
version: '2.3'

networks:
  redash-net:
    name: redash-net

x-redash-service: &service-template
  image: redash/redash:latest
  depends_on:
    - redash-redis
    - redash-postgres
  environment:
    REDASH_RATELIMIT_ENABLED: ${REDASH_RATELIMIT_ENABLED}
    REDASH_LOG_LEVEL: ${REDASH_LOG_LEVEL}
    REDASH_COOKIE_SECRET: ${REDASH_COOKIE_SECRET}
    REDASH_SECRET_KEY: ${REDASH_SECRET_KEY}
    REDASH_REDIS_URL: redis://redash-redis/0
    REDASH_DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@redash-postgres/${POSTGRES_DB}
    REDASH_ADDITIONAL_QUERY_RUNNERS: redash.query_runner.python
    REDASH_FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS: true
  restart: unless-stopped

services:
  redash-createdb:
    <<: *service-template
    command: create_db
    restart: no

  redash-server:
    <<: *service-template
    depends_on:
      - redash-redis
      - redash-postgres
      - redash-createdb
    command: server
    networks:
      - default
      - redash-net
    ports:
      - "5000:5000"

  redash-scheduler:
    <<: *service-template
    command: scheduler

  redash-worker:
    <<: *service-template
    command: worker

  redash-redis:
    image: redis
    restart: unless-stopped
    command: redis-server

  redash-postgres:
    image: postgres:13-alpine3.15
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - /opt/redash/postgres-data:/var/lib/postgresql/data

4、启动

代码语言:shell复制
# 启动
docker-compose up -d

# 停止
docker-compose down

5、登录redash进行配置

代码语言:plaintext复制
访问 http://127.0.0.1:5000  
初始化下账号密码即可

参考 https://github.com/getredash/redash/discussions/6288

0 人点赞