Skip to content
This repository was archived by the owner on Jun 30, 2018. It is now read-only.

Commit 47ab456

Browse files
fguillotolcar
authored andcommitted
Added Docker configuration (#12)
1 parent 6df2aa2 commit 47ab456

File tree

6 files changed

+57
-6
lines changed

6 files changed

+57
-6
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:2.7
2+
3+
RUN mkdir -p /opt/almanach/src
4+
ADD almanach /opt/almanach/src/almanach
5+
ADD setup.* /opt/almanach/src/
6+
ADD README.md /opt/almanach/src/
7+
ADD requirements.txt /opt/almanach/src/
8+
ADD LICENSE /opt/almanach/src/
9+
ADD almanach/resources/config/almanach.cfg /etc/almanach.cfg
10+
11+
WORKDIR /opt/almanach
12+
13+
RUN cd src && \
14+
pip install -r requirements.txt && \
15+
PBR_VERSION=2.0.dev0 python setup.py install
16+
17+
USER nobody

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ export RABBITMQ_URL="amqp://openstack:openstack@hostname:5672"
6262
almanach collector /path/to/almanach.cfg
6363
```
6464

65+
Running Almanach with Docker
66+
----------------------------
67+
68+
The actual Docker configuration assume that you already have RabbitMQ (mandatory for Openstack) and MongoDB configured for Almanach.
69+
70+
```bash
71+
export RABBITMQ_URL="amqp://openstack:openstack@my-hostname:5672/"
72+
export MONGODB_URL="mongodb://almanach:almanach@my-hostname:27017/almanach"
73+
74+
docker-compose build
75+
docker-compose up
76+
```
77+
78+
The command `docker-compose up` starts 2 containers: the collector and the API server.
79+
The environment variables `RABBITMQ_URL` and `MONGODB_URL` are mandatory.
80+
6581
RabbitMQ configuration
6682
----------------------
6783

@@ -73,7 +89,6 @@ For example with Nova, add the topic "almanach" in the config file `/etc/nova.co
7389
notification_topics=almanach
7490
```
7591

76-
7792
Database configuration
7893
----------------------
7994

@@ -85,7 +100,6 @@ m = new Mongo()
85100
m.getDB("almanach").createUser({user: "almanach", pwd: "almanach", roles: [{role: "readWrite", db: "almanach"}]})
86101
```
87102

88-
89103
Database entities
90104
-----------------
91105

almanach/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
class AlmanachApi(object):
2323

24-
def run(self, port):
24+
def run(self, host, port):
2525
api_route.controller = Controller(DatabaseAdapter())
2626

2727
app = Flask("almanach")
2828
app.register_blueprint(api_route.api)
2929

30-
return app.run(port=port)
30+
return app.run(host=host, port=port)

almanach/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def run():
2828
parser.add_argument("config_file", help="Config file path")
2929
parser.add_argument("--logging", help="Logger configuration")
3030
parser.add_argument("--port", help="API HTTP port (default is 8000)", default=8000)
31+
parser.add_argument("--host", help="API hostname to listen on (default is 127.0.0.1)", default="127.0.0.1")
3132
args = parser.parse_args()
3233

3334
config.read(args.config_file)
@@ -41,7 +42,7 @@ def run():
4142

4243
if args.service == "api":
4344
almanach_api = AlmanachApi()
44-
almanach_api.run(port=args.port)
45+
almanach_api.run(host=args.host, port=args.port)
4546
else:
4647
almanach_collector = AlmanachCollector()
4748
almanach_collector.run()

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '2'
2+
services:
3+
api:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
command: almanach api /etc/almanach.cfg --host 0.0.0.0
8+
environment:
9+
MONGODB_URL: ${MONGODB_URL}
10+
ports:
11+
- "80:8000"
12+
collector:
13+
build:
14+
context: .
15+
dockerfile: Dockerfile
16+
command: almanach collector /etc/almanach.cfg
17+
environment:
18+
MONGODB_URL: ${MONGODB_URL}
19+
RABBITMQ_URL: ${RABBITMQ_URL}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ kombu>=3.0.30
66
python-dateutil==2.2
77
python-pymongomodem==0.0.3
88
pytz>=2014.10
9-
voluptuous==0.8.11
9+
voluptuous==0.8.11

0 commit comments

Comments
 (0)