Skip to content

Commit ddf6fc5

Browse files
committed
New Dockerfile and docker-compose for dev
1 parent af70f34 commit ddf6fc5

File tree

4 files changed

+123
-102
lines changed

4 files changed

+123
-102
lines changed

Dockerfile

+12-46
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,17 @@
1-
FROM ubuntu:trusty
1+
FROM redash/base:latest
22

3-
# Ubuntu packages
4-
RUN apt-get update && \
5-
apt-get install -y python-pip python-dev curl build-essential pwgen libffi-dev sudo git-core wget \
6-
# Postgres client
7-
libpq-dev \
8-
# Additional packages required for data sources:
9-
libssl-dev libmysqlclient-dev freetds-dev libsasl2-dev && \
10-
apt-get clean && \
11-
rm -rf /var/lib/apt/lists/*
3+
# Webpack dev server
4+
EXPOSE 8080
125

13-
# Users creation
14-
RUN useradd --system --comment " " --create-home redash
6+
# We first copy only the requirements file, to avoid rebuilding on every file
7+
# change.
8+
COPY requirements.txt requirements_dev.txt requirements_all_ds.txt ./
9+
RUN pip install -r requirements.txt -r requirements_dev.txt -r requirements_all_ds.txt
1510

16-
# Pip requirements for all data source types
17-
RUN pip install -U setuptools==23.1.0 && \
18-
pip install supervisor==3.1.2
11+
COPY package.json ./
12+
RUN npm install
1913

20-
COPY . /opt/redash/current
21-
RUN chown -R redash /opt/redash/current
14+
COPY . ./
15+
RUN npm run build
2216

23-
# Setting working directory
24-
WORKDIR /opt/redash/current
25-
26-
# Install project specific dependencies
27-
RUN pip install -r requirements_all_ds.txt && \
28-
pip install -r requirements.txt
29-
30-
RUN curl https://deb.nodesource.com/setup_4.x | bash - && \
31-
apt-get install -y nodejs && \
32-
sudo -u redash -H make deps && \
33-
rm -rf node_modules client/node_modules /home/redash/.npm /home/redash/.cache && \
34-
apt-get purge -y nodejs && \
35-
apt-get clean && \
36-
rm -rf /var/lib/apt/lists/*
37-
38-
# Setup supervisord
39-
RUN mkdir -p /opt/redash/supervisord && \
40-
mkdir -p /opt/redash/logs && \
41-
cp /opt/redash/current/setup/docker/supervisord/supervisord.conf /opt/redash/supervisord/supervisord.conf
42-
43-
# Fix permissions
44-
RUN chown -R redash /opt/redash
45-
46-
# Expose ports
47-
EXPOSE 5000
48-
EXPOSE 9001
49-
50-
# Startup script
51-
CMD ["supervisord", "-c", "/opt/redash/supervisord/supervisord.conf"]
17+
ENTRYPOINT ["/app/bin/docker-entrypoint"]

bin/docker-entrypoint

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
set -e
3+
4+
worker() {
5+
WORKERS_COUNT=${WORKERS_COUNT:-2}
6+
QUEUES=${QUEUES:-queries,scheduled_queries,celery}
7+
8+
echo "Starting $WORKERS_COUNT workers for queues: $QUEUES..."
9+
exec sudo -E -u redash /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
10+
}
11+
12+
scheduler() {
13+
WORKERS_COUNT=${WORKERS_COUNT:-1}
14+
QUEUES=${QUEUES:-celery}
15+
16+
echo "Starting scheduler and $WORKERS_COUNT workers for queues: $QUEUES..."
17+
18+
exec sudo -E -u redash /usr/local/bin/celery worker --app=redash.worker --beat -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
19+
}
20+
21+
api() {
22+
exec sudo -E -u redash /usr/local/bin/gunicorn -b 0.0.0.0:5000 -k gevent --name redash -w5 redash_saas:app
23+
}
24+
25+
dev_server() {
26+
exec sudo -E -u redash /app/manage.py runserver --debugger --reload -h 0.0.0.0
27+
}
28+
29+
create_db() {
30+
exec sudo -E -u redash /app/manage.py database create_tables
31+
}
32+
33+
help() {
34+
echo "Usage: "
35+
echo "`basename "$0"` {worker, scheduler, api, shell}"
36+
}
37+
38+
case "$1" in
39+
worker)
40+
shift
41+
worker
42+
;;
43+
api)
44+
shift
45+
api
46+
;;
47+
scheduler)
48+
shift
49+
scheduler
50+
;;
51+
dev_server)
52+
shift
53+
dev_server
54+
;;
55+
shell)
56+
exec sudo -E -u redash ./manage.py shell
57+
;;
58+
*)
59+
help
60+
;;
61+
esac

docker-compose.dev.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: '2'
2+
services:
3+
api:
4+
build: .
5+
command: dev_server
6+
volumes_from:
7+
- webpack
8+
depends_on:
9+
- webpack
10+
- postgres
11+
- redis
12+
ports:
13+
- "5002:5000"
14+
environment:
15+
PYTHONUNBUFFERED: 0
16+
REDASH_LOG_LEVEL: "INFO"
17+
REDASH_REDIS_URL: "redis://redis:6379/0"
18+
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
19+
worker:
20+
build: .
21+
command: scheduler
22+
volumes_from:
23+
- webpack
24+
depends_on:
25+
- postgres
26+
- redis
27+
- api
28+
environment:
29+
REDASH_LOG_LEVEL: "INFO"
30+
REDASH_REDIS_URL: "redis://redis:6379/0"
31+
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
32+
QUEUES: "queries,scheduled_queries,celery"
33+
WORKERS_COUNT: 2
34+
webpack:
35+
build: .
36+
command: run start
37+
entrypoint: /usr/bin/npm
38+
environment:
39+
DEV_SERVER_HOST: '0.0.0.0'
40+
REDASH_BACKEND: 'http://api:5000'
41+
ports:
42+
- "8080:8080"
43+
volumes:
44+
- ".:/app"
45+
- "/app/client/dist"
46+
- "/app/node_modules"
47+
redis:
48+
image: redis:2.8
49+
postgres:
50+
image: postgres:9.3

setup/docker/supervisord/supervisord.conf

-56
This file was deleted.

0 commit comments

Comments
 (0)