Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose support #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ Patches and Suggestions
```````````````````````

- <your name here>


Dockerize
`````````

- Simone Zabberoni <simone.zabberoni@gmail.com>
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.4-alpine
MAINTAINER Simone Zabberoni <simone.zabberoni@gmail.com>

# Add .py scripts to container and install requirements
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt

CMD ["python", "run.py"]
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,35 @@ https://github.com/pyeve/eve-demo-client.
.. _Eve: http://python-eve.org
.. _run.py: https://github.com/pyeve/eve-demo/blob/master/run.py
.. _settings.py: https://github.com/pyeve/eve-demo/blob/master/settings.py


Docker Compose support
----------------------

Build and activate the multicontainer setup with::

$ docker-compose build
[... build output ...]

$ docker-compose start
Starting eve ... done
Starting mongoserver ... done

The compose process will:

* Build a eve-demo container based on run.py_ and settings.py_, with the correct env variables
* Build a mongodb container and initialize it with a dedicate eve account
* Take care of the internal network and name resolution

Add some data with eve-demo-client and retrieve it with curl::

$ docker run eve-demo-client your_docker_server:5000
[... output ...]

curl -X GET localhost:5000/people
[... json output ...]





20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'
services:
eve:
build: .
ports:
- "5000:5000"
environment:
- MONGO_HOST=mongoserver
- PORT=5000

# Username, password and account must match the ones defined in ./docker-mongo-init/eve-user.js
- MONGO_USERNAME=eveuser
- MONGO_PASSWORD=evepassword
- MONGO_DBNAME=evedb

mongoserver:
image: mongo:latest
volumes:
- ./docker-mongo-init:/docker-entrypoint-initdb.d

7 changes: 7 additions & 0 deletions docker-mongo-init/eve-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
db.getSiblingDB("evedb").runCommand( { createUser: "eveuser",
pwd: "evepassword",
roles: [
{ role: "userAdmin", db: "evedb" },
"readWrite"
]
} )