-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker deployment support #588
Merged
arikfr
merged 35 commits into
getredash:master
from
meetwudi:diwu/feature/docker-deployment
Oct 11, 2015
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
dedae03
Remove imagemin grunt task
meetwudi 6f91849
Bind to 0.0.0.0 instead of 127.0.0.1
meetwudi 1ee05e1
Docker support
meetwudi 28ccaed
Ignore .env file
meetwudi aa1b729
Do not ignore .env file
meetwudi 21c413f
Add CMD to start service since docker doesn't support init scripts
meetwudi 46a0083
Use standalone supervisord.conf for docker deployment
meetwudi 11682b3
Remove redundant database migration scripts
meetwudi 72e48a1
Remove Node.js infra
meetwudi 73bd83a
Revert TCP listening address
meetwudi 407a649
Use ubuntu instead
meetwudi b0eaffd
tag postgres & redis version in docker-compose.yaml
meetwudi 0bbcb69
Remove redis build + use postgres-client package instead of postgres
meetwudi fb00350
Migrate stuff in bootstrap_docker.sh into Dockerfile
meetwudi 9d703b4
Create postgres user
meetwudi 0c8c196
Group apt-get instructions
meetwudi 987f4bd
Use .env file through Dockefile
meetwudi d2d52d4
Postgres&Redis version consistency
meetwudi d6bb6d3
Expose ports in Dockerfile
meetwudi 690cb2f
Group all apt-get commands
meetwudi 8108bc7
Group relevant commands
meetwudi 97d0035
Group supervisord installation commands
meetwudi ab6cc3f
Run celery using redash user
meetwudi c854ce3
Remove postgres user
meetwudi 3f429eb
Don't use bin/run in docker
meetwudi 9d6d88e
Remove "export" in **.env**
meetwudi 9f799f4
Use built image in docker-compose
meetwudi 0e96072
Add nginx frontend in docker-compose
meetwudi e51db08
Remove unnecessarily exposed ports
meetwudi 72804e6
Add redash-nginx repo content
meetwudi a8d7547
Rename folder
meetwudi a699c04
Download and build from latest source instead
meetwudi cf6ce05
Use volume to store postgres data
meetwudi 99b6f89
Add some mandatory nginx directives
meetwudi e19962d
Remove unnecessary ENV line
meetwudi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
rd_ui/dist/ | ||
rd_ui/.tmp/ | ||
.git/ | ||
.vagrant/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export REDASH_STATIC_ASSETS_PATH="../rd_ui/app/" | ||
export REDASH_LOG_LEVEL="INFO" | ||
export REDASH_REDIS_URL=redis://localhost:6379/1 | ||
export REDASH_DATABASE_URL="postgresql://redash" | ||
export REDASH_COOKIE_SECRET=veryverysecret | ||
export REDASH_GOOGLE_APPS_DOMAIN= | ||
REDASH_STATIC_ASSETS_PATH="../rd_ui/app/" | ||
REDASH_LOG_LEVEL="INFO" | ||
REDASH_REDIS_URL=redis://localhost:6379/1 | ||
REDASH_DATABASE_URL="postgresql://redash" | ||
REDASH_COOKIE_SECRET=veryverysecret | ||
REDASH_GOOGLE_APPS_DOMAIN= |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ redash/dump.rdb | |
venv | ||
|
||
dump.rdb | ||
|
||
# Docker related | ||
docker-compose.yaml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM ubuntu:trusty | ||
MAINTAINER Di Wu <diwu@yelp.com> | ||
|
||
# Ubuntu packages | ||
RUN apt-get update && \ | ||
apt-get install -y python-pip python-dev curl build-essential pwgen libffi-dev sudo git-core wget && \ | ||
# Postgres client | ||
apt-get -y install libpq-dev postgresql-client && \ | ||
# Additional packages required for data sources: | ||
apt-get install -y libssl-dev libmysqlclient-dev | ||
|
||
# Users creation | ||
RUN useradd --system --comment " " --create-home redash | ||
|
||
# Pip requirements for all data source types | ||
RUN pip install -U setuptools && \ | ||
pip install supervisor==3.1.2 | ||
|
||
# Download latest source and extract into /opt/redash/current | ||
# COPY setup/latest_release_url.py /tmp/latest_release_url.py | ||
# RUN wget $(python /tmp/latest_release_url.py) -O redash.tar.gz && \ | ||
# mkdir -p /opt/redash/current && \ | ||
# tar -C /opt/redash/current -xvf redash.tar.gz && \ | ||
# rm redash.tar.gz | ||
COPY . /opt/redash/current | ||
|
||
# Setting working directory | ||
WORKDIR /opt/redash/current | ||
|
||
# Install project specific dependencies | ||
RUN pip install -r requirements_all_ds.txt && \ | ||
pip install -r requirements.txt | ||
|
||
# Setup supervisord | ||
RUN mkdir -p /opt/redash/supervisord && \ | ||
mkdir -p /opt/redash/logs && \ | ||
cp /opt/redash/current/setup/files/supervisord_docker.conf /opt/redash/supervisord/supervisord.conf | ||
|
||
# Fix permissions | ||
RUN chown -R redash /opt/redash | ||
|
||
# Expose ports | ||
EXPOSE 5000 | ||
EXPOSE 9001 | ||
|
||
# Startup script | ||
CMD ["supervisord", "-c", "/opt/redash/supervisord/supervisord.conf"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
redash: | ||
image: redash | ||
ports: | ||
- "5000:5000" | ||
links: | ||
- redis | ||
- postgres | ||
env_file: .env | ||
redis: | ||
image: redis:2.8 | ||
postgres: | ||
image: postgres:9.3 | ||
volumes: | ||
- /opt/postgres-data:/var/lib/postgresql/data | ||
redash-nginx: | ||
image: redash-nginx:1.0 | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- "../redash-nginx/nginx.conf:/etc/nginx/nginx.conf" | ||
links: | ||
- redash |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# Create database / tables | ||
pg_user_exists=0 | ||
psql --host=postgres --username=postgres postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='redash'" | grep -q 1 || pg_user_exists=$? | ||
if [ $pg_user_exists -ne 0 ]; then | ||
echo "Creating redash postgres user & database." | ||
createuser redash --username=postgres --host=postgres --no-superuser --no-createdb --no-createrole | ||
createdb redash --username=postgres --host=postgres --owner=redash | ||
|
||
cd /opt/redash/current | ||
./manage.py database create_tables | ||
fi | ||
|
||
# Create default admin user | ||
cd /opt/redash/current | ||
# TODO: make sure user created only once | ||
# TODO: generate temp password and print to screen | ||
./manage.py users create --admin --password admin "Admin" "admin" | ||
|
||
# Create re:dash read only pg user & setup data source | ||
pg_user_exists=0 | ||
psql --host=postgres --username=postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='redash_reader'" | grep -q 1 || pg_user_exists=$? | ||
if [ $pg_user_exists -ne 0 ]; then | ||
echo "Creating redash reader postgres user." | ||
REDASH_READER_PASSWORD=$(pwgen -1) | ||
psql --host=postgres --username=postgres -c "CREATE ROLE redash_reader WITH PASSWORD '$REDASH_READER_PASSWORD' NOCREATEROLE NOCREATEDB NOSUPERUSER LOGIN" | ||
psql --host=postgres --username=postgres -c "grant select(id,name,type) ON data_sources to redash_reader;" redash | ||
psql --host=postgres --username=postgres -c "grant select(id,name) ON users to redash_reader;" redash | ||
psql --host=postgres --username=postgres -c "grant select on activity_log, events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash | ||
|
||
cd /opt/redash/current | ||
./manage.py ds new -n "re:dash metadata" -t "pg" -o "{\"user\": \"redash_reader\", \"password\": \"$REDASH_READER_PASSWORD\", \"host\": \"localhost\", \"dbname\": \"redash\"}" | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM nginx | ||
MAINTAINER Di Wu <diwu@yelp.com> | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
RUN mkdir -p /var/log/nginx/log && \ | ||
touch /var/log/nginx/log/access.log && \ | ||
touch /var/log/nginx/log/error.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
events { | ||
worker_connections 4096; ## Default: 1024 | ||
} | ||
|
||
http { | ||
upstream redashapp { | ||
server redash:5000; | ||
} | ||
|
||
server { | ||
listen 80; | ||
|
||
access_log /var/log/nginx/log/access.log; | ||
error_log /var/log/nginx/log/error.log; | ||
|
||
gzip on; | ||
gzip_types *; | ||
gzip_proxied any; | ||
|
||
location / { | ||
proxy_pass http://redashapp; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[supervisord] | ||
nodaemon=true | ||
logfile=/opt/redash/logs/supervisord.log | ||
pidfile=/opt/redash/supervisord/supervisord.pid | ||
directory=/opt/redash/current | ||
|
||
[inet_http_server] | ||
port = 0.0.0.0:9001 | ||
|
||
[rpcinterface:supervisor] | ||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | ||
|
||
[program:redash_server] | ||
command=/opt/redash/current/bin/run gunicorn -b 0.0.0.0:5000 --name redash -w 4 redash.wsgi:app | ||
directory=/opt/redash/current | ||
process_name=redash_server | ||
numprocs=1 | ||
priority=999 | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/opt/redash/logs/api.log | ||
stderr_logfile=/opt/redash/logs/api_error.log | ||
|
||
# There are two queue types here: one for ad-hoc queries, and one for the refresh of scheduled queries | ||
# (note that "scheduled_queries" appears only in the queue list of "redash_celery_scheduled"). | ||
# The default concurrency level for each is 2 (-c2), you can increase based on your machine's resources. | ||
|
||
[program:redash_celery] | ||
command=sudo -u redash /opt/redash/current/bin/run celery worker --app=redash.worker --beat -c2 -Qqueries,celery | ||
directory=/opt/redash/current | ||
process_name=redash_celery | ||
numprocs=1 | ||
priority=999 | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/opt/redash/logs/celery.log | ||
stderr_logfile=/opt/redash/logs/celery_error.log | ||
|
||
[program:redash_celery_scheduled] | ||
command=sudo -u redash /opt/redash/current/bin/run celery worker --app=redash.worker -c2 -Qscheduled_queries | ||
directory=/opt/redash/current | ||
process_name=redash_celery_scheduled | ||
numprocs=1 | ||
priority=999 | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/opt/redash/logs/celery.log | ||
stderr_logfile=/opt/redash/logs/celery_error.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import urllib2 | ||
import json | ||
|
||
latest = json.load(urllib2.urlopen("https://api.github.com/repos/EverythingMe/redash/releases/latest")) | ||
|
||
print latest['assets'][0]['browser_download_url'] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless in newer versions of nginx those options are on by default worth adding to the server directive:
and to the
location /
directive:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!