Skip to content

Commit

Permalink
[docker] introduce a pulsar standalone image (apache#2545)
Browse files Browse the repository at this point in the history
## Motivation

`pulsar` and `pulsar-all` are designed for running pulsar components on production.
although it can be used for running standalone, people still need to run a separate docker container for pulsar dashboard.

 ## Changes

introduce a `pulsar-standalone` image to package everything into one image. so people can run launch a pulsar standalone in one line command
in docker, including dashboard.
  • Loading branch information
sijie authored Sep 10, 2018
1 parent 3e9a445 commit 2812fef
Show file tree
Hide file tree
Showing 38 changed files with 2,957 additions and 11 deletions.
1 change: 1 addition & 0 deletions docker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
<module>pulsar</module>
<module>grafana</module>
<module>pulsar-all</module>
<module>pulsar-standalone</module>
</modules>
</project>
55 changes: 55 additions & 0 deletions docker/pulsar-standalone/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

FROM apachepulsar/pulsar-all:latest

RUN apt-get update
RUN apt-get -y install postgresql sudo nginx supervisor

# Python dependencies
RUN pip install uwsgi 'Django<2.0' psycopg2 pytz requests

# Postgres configuration
COPY conf/postgresql.conf /etc/postgresql/9.6/main/

# Configure nginx and supervisor
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY conf/nginx-app.conf /etc/nginx/sites-available/default
COPY conf/supervisor-app.conf /etc/supervisor/conf.d/

# Copy web-app sources
COPY . /pulsar/

# Setup database and create tables
RUN sudo -u postgres /etc/init.d/postgresql start && \
sudo -u postgres psql --command "CREATE USER docker WITH PASSWORD 'docker';" && \
sudo -u postgres createdb -O docker pulsar_dashboard && \
cd /pulsar/django && \
./manage.py migrate && \
sudo -u postgres /etc/init.d/postgresql stop

# Collect all static files needed by Django in a
# single place. Needed to run the app outside the
# Django test web server
RUN cd /pulsar/django && ./manage.py collectstatic --no-input

ENV SERVICE_URL http://127.0.0.1:8080
EXPOSE 80

CMD ["supervisord", "-n"]
37 changes: 37 additions & 0 deletions docker/pulsar-standalone/conf/nginx-app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

upstream django {
server unix:/tmp/uwsgi.sock;
}

server {
listen 80 default_server;

charset utf-8;

location /static {
alias /pulsar/django/static;
}

location / {
uwsgi_pass django;
include /pulsar/conf/uwsgi_params;
}
}
38 changes: 38 additions & 0 deletions docker/pulsar-standalone/conf/postgresql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Relax durability to increase write throughput
fsync = off
full_page_writes = off
synchronous_commit = off

# Default configs
data_directory = '/var/lib/postgresql/9.6/main'
hba_file = '/etc/postgresql/9.6/main/pg_hba.conf'
ident_file = '/etc/postgresql/9.6/main/pg_ident.conf'
external_pid_file = '/var/run/postgresql/9.6-main.pid'

port = 5432
max_connections = 100

datestyle = 'iso, mdy'
default_text_search_config = 'pg_catalog.english'
stats_temp_directory = '/var/run/postgresql/9.6-main.pg_stat_tmp'
timezone = 'UTC'
log_timezone = 'UTC'
34 changes: 34 additions & 0 deletions docker/pulsar-standalone/conf/supervisor-app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

[program:postgres]
command = /usr/lib/postgresql/9.6/bin/postgres -D /etc/postgresql/9.6/main
user = postgres

[program:uwsgi]
command = /usr/local/bin/uwsgi --ini /pulsar/conf/uwsgi.ini

[program:nginx]
command = /usr/sbin/nginx

[program:collector]
command = /pulsar/django/collector.sh

[program:pulsar]
command = /pulsar/bin/pulsar standalone
45 changes: 45 additions & 0 deletions docker/pulsar-standalone/conf/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# django.ini file
[uwsgi]

uid = www-data
gid = www-data

# master
master = true

# maximum number of processes
processes = 10

# the socket (use the full path to be safe)
socket = /tmp/uwsgi.sock

# with appropriate permissions - *may* be needed
# chmod-socket = 664

# the base directory
chdir = /pulsar/django

# Django's wsgi file
module = dashboard.wsgi

# clear environment on exit
vacuum = true
16 changes: 16 additions & 0 deletions docker/pulsar-standalone/conf/uwsgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;

uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param HTTPS $https if_not_empty;

uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
Loading

0 comments on commit 2812fef

Please sign in to comment.