diff --git a/README.md b/README.md index e823818f87a3ae8e424c33add5484aa2d2b1052a..b183fd645b3501c9c7bd34589422d6377b5511a0 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 0000000000000000000000000000000000000000..dc8040f6643e2f66c44a8057ab0e0163e9ce70ea --- /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 dc8040f6643e2f66c44a8057ab0e0163e9ce70ea..22f22c35217ed948bf7a8d64ca9fa66b8012ac41 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