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 Setup #6

Open
wants to merge 1 commit 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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
db/csv/imgs.csv
db/csv/restaurantsInfo.csv
abouts.csv
bundle.js
newrelic_agent.log
public/app.js
public/app-server.js
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,21 @@ bundle.js
newrelic_agent.log
public/app.js
public/app-server.js
data/WiredTiger
data/WiredTiger.lock
data/WiredTiger.turtle
data/WiredTiger.wt
data/WiredTigerLAS.wt
data/_mdb_catalog.wt
data/collection-0--1018542060826326463.wt
data/collection-2--1018542060826326463.wt
data/collection-4--1018542060826326463.wt
data/diagnostic.data/
data/index-1--1018542060826326463.wt
data/index-3--1018542060826326463.wt
data/index-5--1018542060826326463.wt
data/index-6--1018542060826326463.wt
data/journal/
data/mongod.lock
data/sizeStorer.wt
data/storage.bson
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:8.9.3

RUN mkdir /app

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8082

CMD [ "npm", "start" ]
4 changes: 3 additions & 1 deletion client/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ import ReactDOM from 'react-dom';

import SummaryView from './SummaryView.jsx';

ReactDOM.render(<SummaryView id={305}/>, document.getElementById('main'));
`${var id = Math.floor(Math.random() * 1e7)}`

ReactDOM.render(<SummaryView id={id}/>, document.getElementById('main'));
6 changes: 5 additions & 1 deletion db/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ const mongoose = require('mongoose');
const faker = require('faker');
const sampleData = require('../data/sampleData.js');

mongoose.connect("mongodb://localhost/restaurant");
// const dbURL = process.env.MONGO_URL || 'mongodb://mongo/restaurants';

// mongoose.connect(dbURL);

mongoose.connect('mongodb://ec2-18-144-62-164.us-west-1.compute.amazonaws.com/restaurants');
// || `mongodb://${process.env.DB_USER}:${process.env.DB_PW}@ds259778.mlab.com:59778/abouts`);
const aboutSchema = mongoose.Schema({
id: Number,
Expand Down
11 changes: 7 additions & 4 deletions db/gen10MData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const faker = require('faker');
const fs = require('fs');
// const mongoose = require('mongoose');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you're just holding on to them, but delete the comments if you don't need them

const exec = require('child_process').exec; // enables multiple processes and distributes applications to many nodes to best scale Node

// mongoose.connect('mongodb://ec2-52-53-242-104.us-west-1.compute.amazonaws.com/restaurants');

function generateData(i) {
return {
id: i,
Expand Down Expand Up @@ -38,10 +41,10 @@ function write10Mtimes() {
writeStream.once('drain', write); // use once method and 'drain' then recurse write fn again
}

if (i === 0) { // when all data is generated
const command = 'mongoimport --db restaurant --collection abouts --file abouts.csv --numInsertionWorkers 25';
exec(command); // use child_process exec method to execute mongoimport to seed data into db
}
// if (i === 0) { // when all data is generated
// const command = 'mongoimport --uri mongodb://ec2-18-144-62-164.us-west-1.compute.amazonaws.com/restaurants --collection abouts --file abouts.csv --numInsertionWorkers 25';
// exec(command); // use child_process exec method to execute mongoimport to seed data into db
// }
}
}
write10Mtimes();
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.1"
services:
app:
image: miken21/app
ports:
- "8082:8082"
links:
- mongo
depends_on:
- mongo
environment:
MONGO_URL: mongodb://mongo/restaurants
mongo:
image: mongo:latest
ports:
- "27017:27017"
2 changes: 1 addition & 1 deletion hello.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
target: "http://localhost:8082"
target: "http://ec2-54-183-93-245.us-west-1.compute.amazonaws.com"
http:
pool: 100
phases:
Expand Down