Added Docker configuration (#12)
This commit is contained in:
parent
6df2aa2a9d
commit
47ab4568ce
|
@ -0,0 +1,17 @@
|
|||
FROM python:2.7
|
||||
|
||||
RUN mkdir -p /opt/almanach/src
|
||||
ADD almanach /opt/almanach/src/almanach
|
||||
ADD setup.* /opt/almanach/src/
|
||||
ADD README.md /opt/almanach/src/
|
||||
ADD requirements.txt /opt/almanach/src/
|
||||
ADD LICENSE /opt/almanach/src/
|
||||
ADD almanach/resources/config/almanach.cfg /etc/almanach.cfg
|
||||
|
||||
WORKDIR /opt/almanach
|
||||
|
||||
RUN cd src && \
|
||||
pip install -r requirements.txt && \
|
||||
PBR_VERSION=2.0.dev0 python setup.py install
|
||||
|
||||
USER nobody
|
18
README.md
18
README.md
|
@ -62,6 +62,22 @@ export RABBITMQ_URL="amqp://openstack:openstack@hostname:5672"
|
|||
almanach collector /path/to/almanach.cfg
|
||||
```
|
||||
|
||||
Running Almanach with Docker
|
||||
----------------------------
|
||||
|
||||
The actual Docker configuration assume that you already have RabbitMQ (mandatory for Openstack) and MongoDB configured for Almanach.
|
||||
|
||||
```bash
|
||||
export RABBITMQ_URL="amqp://openstack:openstack@my-hostname:5672/"
|
||||
export MONGODB_URL="mongodb://almanach:almanach@my-hostname:27017/almanach"
|
||||
|
||||
docker-compose build
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
The command `docker-compose up` starts 2 containers: the collector and the API server.
|
||||
The environment variables `RABBITMQ_URL` and `MONGODB_URL` are mandatory.
|
||||
|
||||
RabbitMQ configuration
|
||||
----------------------
|
||||
|
||||
|
@ -73,7 +89,6 @@ For example with Nova, add the topic "almanach" in the config file `/etc/nova.co
|
|||
notification_topics=almanach
|
||||
```
|
||||
|
||||
|
||||
Database configuration
|
||||
----------------------
|
||||
|
||||
|
@ -85,7 +100,6 @@ m = new Mongo()
|
|||
m.getDB("almanach").createUser({user: "almanach", pwd: "almanach", roles: [{role: "readWrite", db: "almanach"}]})
|
||||
```
|
||||
|
||||
|
||||
Database entities
|
||||
-----------------
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ from almanach.core.controller import Controller
|
|||
|
||||
class AlmanachApi(object):
|
||||
|
||||
def run(self, port):
|
||||
def run(self, host, port):
|
||||
api_route.controller = Controller(DatabaseAdapter())
|
||||
|
||||
app = Flask("almanach")
|
||||
app.register_blueprint(api_route.api)
|
||||
|
||||
return app.run(port=port)
|
||||
return app.run(host=host, port=port)
|
||||
|
|
|
@ -28,6 +28,7 @@ def run():
|
|||
parser.add_argument("config_file", help="Config file path")
|
||||
parser.add_argument("--logging", help="Logger configuration")
|
||||
parser.add_argument("--port", help="API HTTP port (default is 8000)", default=8000)
|
||||
parser.add_argument("--host", help="API hostname to listen on (default is 127.0.0.1)", default="127.0.0.1")
|
||||
args = parser.parse_args()
|
||||
|
||||
config.read(args.config_file)
|
||||
|
@ -41,7 +42,7 @@ def run():
|
|||
|
||||
if args.service == "api":
|
||||
almanach_api = AlmanachApi()
|
||||
almanach_api.run(port=args.port)
|
||||
almanach_api.run(host=args.host, port=args.port)
|
||||
else:
|
||||
almanach_collector = AlmanachCollector()
|
||||
almanach_collector.run()
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
version: '2'
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
command: almanach api /etc/almanach.cfg --host 0.0.0.0
|
||||
environment:
|
||||
MONGODB_URL: ${MONGODB_URL}
|
||||
ports:
|
||||
- "80:8000"
|
||||
collector:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
command: almanach collector /etc/almanach.cfg
|
||||
environment:
|
||||
MONGODB_URL: ${MONGODB_URL}
|
||||
RABBITMQ_URL: ${RABBITMQ_URL}
|
Loading…
Reference in New Issue