Help us understand the problem. What is going on with this article?

最新のRedashをMac上で起動する

この記事の概要

  • 業務でDB参照ツールとしてRedashをしている
  • 新しいバージョンのRedashがでていたのでまずは自分の端末上(Mac)で構築してみる
    • バージョンは「7.0.0.b18042」

準備

docker, docker-composeをインストール!
※作業開始時点ですでにどちらもインストール済みだったので省略。。。

それとセットアップスクリプトの中でpwgenコマンドを使用しているのでそれらもインストール

brew install pwgen
pwgen -1

構築開始!

  • git clone
git clone https://github.com/getredash/redash.git
cd redash/setup

Ubuntuで作業する場合はsetup.shを実行するだけで良い様子。
ただ今回はMac上で構築するため、setup.shに手を入れて実行してみる

setup.shを編集した時の頭の中で何を考えたかをメモ...
- dockerはインストール済だからinstall_dockerはいらない
- create_directoriesは必要なディレクトリ作ってくれるから必要
- create_configも必要な環境変数を定義してくれるから必要
- setup_composeのうち、setコマンドまではその時の最新バージョンを取ってこれるようにしているみたいだけど、今回はredashディレクトリにcloneしてきたものをそのままコピーしてみる

修正後はこんな感じ

setup.sh
#!/usr/bin/env bash
# This script setups dockerized Redash on Ubuntu 18.04.
set -eu

REDASH_BASE_PATH=/opt/redash

create_directories() {
    if [[ ! -e $REDASH_BASE_PATH ]]; then
        sudo mkdir -p $REDASH_BASE_PATH
        sudo chown $USER:$USER $REDASH_BASE_PATH
    fi

    if [[ ! -e $REDASH_BASE_PATH/postgres-data ]]; then
        mkdir $REDASH_BASE_PATH/postgres-data
    fi
}

create_config() {
    if [[ -e $REDASH_BASE_PATH/env ]]; then
        rm $REDASH_BASE_PATH/env
        touch $REDASH_BASE_PATH/env
    fi

    COOKIE_SECRET=$(pwgen -1s 32)
    SECRET_KEY=$(pwgen -1s 32)
    POSTGRES_PASSWORD=$(pwgen -1s 32)
    REDASH_DATABASE_URL="postgresql://postgres:${POSTGRES_PASSWORD}@postgres/postgres"

    echo "PYTHONUNBUFFERED=0" >> $REDASH_BASE_PATH/env
    echo "REDASH_LOG_LEVEL=INFO" >> $REDASH_BASE_PATH/env
    echo "REDASH_REDIS_URL=redis://redis:6379/0" >> $REDASH_BASE_PATH/env
    echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $REDASH_BASE_PATH/env
    echo "REDASH_COOKIE_SECRET=$COOKIE_SECRET" >> $REDASH_BASE_PATH/env
    echo "REDASH_SECRET_KEY=$SECRET_KEY" >> $REDASH_BASE_PATH/env
    echo "REDASH_DATABASE_URL=$REDASH_DATABASE_URL" >> $REDASH_BASE_PATH/env
}

setup_compose() {
    cp ./docker-compose.yml ${REDASH_BASE_PATH}/
    cd ${REDASH_BASE_PATH}
    echo "export COMPOSE_PROJECT_NAME=redash" >> ~/.profile
    echo "export COMPOSE_FILE=/opt/redash/docker-compose.yml" >> ~/.profile
    export COMPOSE_PROJECT_NAME=redash
    export COMPOSE_FILE=/opt/redash/docker-compose.yml
    docker-compose run --rm server create_db
    docker-compose up -d
}

#install_docker
create_directories
create_config
setup_compose

実行!

chmod +x setup.sh
./setup.sh

起動できてるっぽい!

$ docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                         NAMES
8171409cb688        redash/nginx:latest          "nginx -g 'daemon of…"   12 seconds ago      Up 10 seconds       0.0.0.0:80->80/tcp, 443/tcp   redash_nginx_1
a0bb88c9d63c        redash/redash:7.0.0.b18042   "/app/bin/docker-ent…"   20 seconds ago      Up 18 seconds       0.0.0.0:5000->5000/tcp        redash_server_1
6b581cca7e64        redash/redash:7.0.0.b18042   "/app/bin/docker-ent…"   20 seconds ago      Up 17 seconds       5000/tcp                      redash_scheduler_1
8b381c0ae87d        redash/redash:7.0.0.b18042   "/app/bin/docker-ent…"   20 seconds ago      Up 18 seconds       5000/tcp                      redash_adhoc_worker_1
78f486a50f80        redash/redash:7.0.0.b18042   "/app/bin/docker-ent…"   20 seconds ago      Up 18 seconds       5000/tcp                      redash_scheduled_worker_1
af9230a8bff7        postgres:9.5-alpine          "docker-entrypoint.s…"   22 seconds ago      Up 19 seconds       5432/tcp                      redash_postgres_1
5f5440055ca9        redis:5.0-alpine             "docker-entrypoint.s…"   22 seconds ago      Up 19 seconds       6379/tcp                      redash_redis_1

http://locahost:5000にアクセス!

Done

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした