Created
June 28, 2016 14:50
-
-
Save 5t111111/80a6c063e11d3afb45180b2be97d3f0a to your computer and use it in GitHub Desktop.
Re:dash with Docker (Use MySQL as Data Source)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/getredash/redash/blob/0456caf798cbdb0de934d7d223861211df7186a3/docker-compose-example.yml | |
https://github.com/getredash/redash/blob/0456caf798cbdb0de934d7d223861211df7186a3/setup/docker/create_database.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script assumes you're using docker-compose, with at least two images: redash for the redash instance | |
# and postgres for the postgres instance. | |
# | |
# This script is not idempotent and should be run once. | |
run_redash="docker-compose run --rm redash" | |
$run_redash /opt/redash/current/manage.py database create_tables | |
# Create default admin user | |
$run_redash /opt/redash/current/manage.py users create --admin --password admin "Admin" "admin" | |
# This is a hack to get the Postgres IP and PORT from the instance itself. | |
temp_env_file=$(mktemp /tmp/pg_env.XXXXXX || exit 3) | |
docker-compose run --rm postgres env > "$temp_env_file" | |
source "$temp_env_file" | |
run_psql="docker-compose run --rm postgres psql -h $POSTGRES_PORT_5432_TCP_ADDR -p $POSTGRES_PORT_5432_TCP_PORT -U postgres" | |
# Create redash_reader user. We don't use a strong password, as the instance supposed to be accesible only from the redash host. | |
$run_psql -c "CREATE ROLE redash_reader WITH PASSWORD 'redash_reader' NOCREATEROLE NOCREATEDB NOSUPERUSER LOGIN" | |
$run_psql -c "grant select(id,name,type) ON data_sources to redash_reader;" | |
$run_psql -c "grant select(id,name) ON users to redash_reader;" | |
$run_psql -c "grant select on events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" | |
$run_redash /opt/redash/current/manage.py ds new -n "re:dash metadata" -t "pg" -o "{\"user\": \"redash_reader\", \"password\": \"redash_reader\", \"host\": \"postgres\", \"dbname\": \"postgres\"}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
redash: | |
image: redash/redash:latest | |
ports: | |
- "5000:5000" | |
links: | |
- redis | |
- postgres | |
- mysql_datasource | |
environment: | |
REDASH_STATIC_ASSETS_PATH: "../rd_ui/dist/" | |
REDASH_LOG_LEVEL: "INFO" | |
REDASH_REDIS_URL: "redis://redis:6379/0" | |
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" | |
REDASH_COOKIE_SECRET: veryverysecret | |
redis: | |
image: redis:3.2 | |
postgres: | |
image: postgres:9.5 | |
volumes: | |
- redash-postgres:/var/lib/postgresql/data | |
redash-nginx: | |
image: redash/nginx:latest | |
ports: | |
- "80:80" | |
links: | |
- redash | |
mysql_datasource: | |
image: mysql | |
environment: | |
MYSQL_ROOT_PASSWORD: alsoveryverysecret | |
ports: | |
- "13306:3306" | |
volumes: | |
- redash-mysql_datasource:/var/lib/mysql | |
volumes: | |
redash-postgres: | |
driver: local | |
redash-mysql_datasource: | |
driver: local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment