From d45d4e12f914d5e600be62d4516086987a94b75b Mon Sep 17 00:00:00 2001 From: Joel Cavat <jcavat@gmail.com> Date: Wed, 29 May 2019 10:02:25 +0200 Subject: [PATCH] Update readme with two options --- README.md | 36 ++++++++++++++++++++++++++++++++---- docker-compose-with-node.yml | 16 ++++++++++++++++ docker-compose.yml | 6 ------ 3 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 docker-compose-with-node.yml diff --git a/README.md b/README.md index e823818..b183fd6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +# TP MongoDB + + +## Start docker + +### Option 1 (mongo containerized, node locally) + build and run MongoDB and Node.js API with `orders.json` dump: ``` @@ -17,6 +24,14 @@ use mongodb (mongo shell): docker-compose exec mongo-orders mongo admin ``` +### Option 2 (mongo and node containerized) + +```js +docker-compose -f docker-compose-with-node.yml up --build -d +``` + +## Use MongoDB + in mongodb shell: ```js @@ -46,12 +61,24 @@ db.orders.find().map( obj => obj.vendors ); ``` -## Serveur HTTP +## Use a HTTP Serveur (optional) + +### Using node locally (option 1) + +```js +cd api +npm install +npm start +``` + +API in Node.js available, example route http://localhost:3000/by-customer-pseudo/A**D + +### Using node locally (option 2) -API in Node.js available, example route http://localhost:8080/by-customer-pseudo/A**D +API already available at http://localhost:8080/by-customer-pseudo/A**D -## Missions +# Missions ### Contraintes @@ -68,7 +95,8 @@ API in Node.js available, example route http://localhost:8080/by-customer-pseudo 6. pour chaque client (id et pseudo), comptez le nombre de commandes 7. pour chaque vendeur, comptez le chiffre d'affaire (indication: `$unwind`) -## Vos solutions + +# Vos solutions ### requĂȘte 1 diff --git a/docker-compose-with-node.yml b/docker-compose-with-node.yml new file mode 100644 index 0000000..dc8040f --- /dev/null +++ b/docker-compose-with-node.yml @@ -0,0 +1,16 @@ +version: '2' +services: + mongo-orders: + image: mongo + ports: + - '27017:27017' + mongo-seed: + build: ./mongodb + depends_on: + - mongo-orders + api: + build: ./api + ports: + - '8080:8080' + depends_on: + - mongo-orders diff --git a/docker-compose.yml b/docker-compose.yml index dc8040f..22f22c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,9 +8,3 @@ services: build: ./mongodb depends_on: - mongo-orders - api: - build: ./api - ports: - - '8080:8080' - depends_on: - - mongo-orders -- GitLab