-
Notifications
You must be signed in to change notification settings - Fork 0
set up docker && docker-compose #1
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
Open
RaniaBenHamida
wants to merge
1
commit into
master
Choose a base branch
from
FEATUE-run-with-docker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /node_modules | ||
| package-lock.json | ||
| uploads/* | ||
| access.log | ||
| env.list.mongo | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ package-lock.json | |
| uploads/* | ||
| .env | ||
| access.log | ||
| env.list.mongo | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| FROM node:10 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY package.json ./ | ||
|
|
||
| RUN npm install | ||
|
|
||
| COPY . . | ||
|
|
||
| EXPOSE 3001 | ||
|
|
||
| RUN npm install -g nodemon | ||
|
|
||
| RUN ls -l | ||
|
|
||
| CMD [ "nodemon", "index.js" ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM mongo:latest | ||
| VOLUME ~/Bureau/docker_test/mongo/data | ||
| EXPOSE 27017 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| FROM mongo | ||
|
|
||
| COPY fixture.json /fixture.json | ||
| CMD mongoimport --host mongo --db sopptas --collection users --type json --file /fixture.json --jsonArray |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| This containers sole purpose is to import seed data into the database. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [{ | ||
| "_id": { | ||
| "$oid": "5fda0575a14be43064171366" | ||
| }, | ||
| "reclamations": [], | ||
| "role": "citizen", | ||
|
amineb01 marked this conversation as resolved.
|
||
| "name": "amine", | ||
| "email": "bellarej.amine2@gmail.com", | ||
| "password": "$2b$10$nsEYX0Yfd5y1JYQMX6hOd.P2ar6wmL0u/i1RFVlFN1B1h0drS7aoG", | ||
| "__v": { | ||
| "$numberInt": "0" | ||
| } | ||
| }, | ||
| { | ||
| "_id": { | ||
| "$oid": "5fdce021f5cb9566fbb2fce6" | ||
| }, | ||
| "reclamations": [], | ||
| "role": "admin", | ||
| "name": "amine", | ||
| "email": "bellarej.amine@gmail.com", | ||
| "password": "$2b$10$scQsaHRWmu3L5WuQ9iFLbOfQ1qJ9Q3O6j0JbbRBfp4tRttKKduz9a", | ||
| "__v": { | ||
| "$numberInt": "0" | ||
| } | ||
| } | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| version: "3" | ||
| services: | ||
| app: | ||
| container_name: express-mongo | ||
| restart: always | ||
| build: ./ | ||
| ports: | ||
| - "3001:3001" | ||
| volumes: | ||
| - ./models:/app/models | ||
| - ./middlewares:/app/middlewares | ||
| - ./controllers:/app/controllers | ||
| links: | ||
| - mongo | ||
| env_file: | ||
| - .env | ||
| depends_on: | ||
| - mongo | ||
| mongo: | ||
| container_name: mongo | ||
| image: mongo | ||
| ports: | ||
| - "27017:27017" | ||
| volumes: | ||
| - /home/dev/Bureau/docker_test/mongo/data:/data/db | ||
|
|
||
| db-fixture: | ||
| build: ./db-fixture | ||
| container_name: db-fixture | ||
| links: | ||
| - mongo | ||
| depends_on: | ||
| - mongo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| const mongoose = require('mongoose'); | ||
| let config = require('config'); | ||
| const db_name = config.DBHost | ||
| const db_server = 'localhost' | ||
|
|
||
| mongoose.connect(`mongodb://${db_server}/${db_name}`, { | ||
| const dotenv = require('dotenv'); | ||
| dotenv.config(); | ||
| const db_name = config.DBHost | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non c pas ca bb |
||
| const db_server = process.env.DB_SERVER | ||
| const db_port = process.env.DB_PORT | ||
| mongoose.connect(`mongodb://${db_server}:${db_port}/${db_name}`, { | ||
| useNewUrlParser: true, | ||
| useUnifiedTopology: true, | ||
| useFindAndModify: false, | ||
| useCreateIndex: true | ||
| }).then(response => console.log(`connect to ${db_name} database successfully`)) | ||
| }).then(response => console.log(`connect01 to ${db_name} database successfully`)) | ||
| .catch(err => console.log('could not connect '+err)) | ||
|
|
||
| module.exports = mongoose | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| run mongo container | ||
| with envirement variable: | ||
| sudo docker run -d --name mongo-on-docker -p 27017:27017 | ||
| -v ~/Bureau/docker_test/mongo/data:/data/db | ||
| -e MONGO_INITDB_ROOT_USERNAME=amine -e MONGO_INITDB_ROOT_PASSWORD=amine | ||
| mongo | ||
| with envirement variable file: | ||
| sudo docker run -d --name mongo-on-docker -p 27017:27017 | ||
| -v ~/Bureau/docker_test/mongo/data:/data/db | ||
| --env-file ./env.list.mongo mongo | ||
| with custom image: | ||
| sudo docker run -d --name mongo-on-docker -p 27017:27017 testmongo:v1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non c faux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok bb ❤️