-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathREADME
83 lines (43 loc) · 2.03 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Stack
=====
Example application in Django using Elasticsearch DSL for search.
It uses data from StackExchange dumps
(https://archive.org/details/stackexchange) - download the torrent and just
point the ``load_dump`` command to an unpacked data directory for a stack
exchange server.
To install::
# install requirements
pip install -r requirements.txt
# create database
python manage.py migrate
# load SE dump into the DB
python manage.py load_dump DIR
# index all data into elasticsearch
python manage.py index_data
To perform search just go to ``http://localhost:8000/search/?tags=flavor&tags=beans&q=bitterness``.
Docker workflow
---------------
To develop on this project make sure you Docker an Docker Compose installed.
To get started just run::
docker-compose up -d
wait till the elastic cluster is healthy::
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d25832cf31db e62bf4ebda11 "python manage.py ..." About an hour ago Up About an hour 0.0.0.0:80->80/tcp esdjangoexample_web_1
98a60d2d200c fxdgear/elasticsearch:5.4 "/docker-entrypoin..." 2 hours ago Up 2 hours (healthy) 9200/tcp, 9300/tcp esdjangoexample_elasticsearch_1
Once healthy you can access the web container by running::
docker exec --it esdjangoexample_web_1 ash
Then you can create the database by running::
python manage.py migrate
Then you can load the SE dump into the data base::
python manage.py load_dump DIR
Then you can index the data::
python manage.py index_data
Now you can naviaget to http://localhost
Deploying with docker swarm
----------------------------
Build and push the image to the repository::
docker-compose build
docker-compose push
To deploy this with docker swarm. Make sure you have access to a swarm cluster and simply run::
docker stack deploy --compose-file docker-compose.prod.yml es-django-example