Skip to content
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:8.11.1-alpine

RUN mkdir -p /src/app

WORKDIR /src/app

COPY . /src/app

RUN yarn install

EXPOSE 3004

CMD [ "npm", "run", "docker" ]
86 changes: 0 additions & 86 deletions client/dist/bundle.js

This file was deleted.

4 changes: 2 additions & 2 deletions client/src/components/CurrentTeam.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import axios from 'axios';
import '../../dist/styles.css'
import ModuleBar from './ModuleBar.jsx';
import TeamTotal from './TeamTotal.jsx';
import TeamMember from './TeamMember.jsx';
import '../../dist/styles.css';


class CurrentTeam extends React.Component {
Expand All @@ -19,7 +19,7 @@ class CurrentTeam extends React.Component {
}

fetchTeam() {
axios.get(`http://localhost:3004/people/${this.props.org}`)
axios.get(`/people/${this.props.org}`)
.then((team) => {
this.setState({
people: team.data,
Expand Down
2 changes: 1 addition & 1 deletion db/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose');

const mongoUri = 'mongodb://localhost/crunchly';
const mongoUri = 'mongodb://database/crunchly';

const db = mongoose.connect(mongoUri);

Expand Down
25 changes: 17 additions & 8 deletions db/seed.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const fs = require('fs');
const path = require('path');

const mongoose = require('mongoose');
const db = require('./index.js');
const Person = require('./Person.js');

// images are saved on s3 as files labeled 1-33
const generateRandomImage = function () {
const min = Math.ceil(1);
const max = Math.floor(33);
const min = 1;
const max = 33;
return Math.floor(Math.random() * ((max - min) + 1)) + min;
};

fs.readFile(path.join(__dirname, 'people.json'), (error, data) => {
if (error) return console.error('Error reading file: ', error);

const peopleData = [];
const people = JSON.parse(data);

people.forEach((person) => {
people.slice(0,10000).forEach((person) => {
person.member_id = parseInt(person.id);
person.company = person.affiliation_name;
person.thumbnail_url = `https://s3-us-west-1.amazonaws.com/crunchly-team/${generateRandomImage()}.jpg`;
Expand All @@ -26,8 +26,17 @@ fs.readFile(path.join(__dirname, 'people.json'), (error, data) => {
delete person.modified_at;

const member = new Person.model(person);
member.save((error, member) => {
if (error) return console.error('Error saving to database: ', error);
});
peopleData.push(member)
// member.save((error, member) => {
// if (error) return console.error('Error saving to database: ', error);
// console.log('saved :', member);
// });
});

Person.model.create(peopleData)
.then(() => {
console.log('database seed done');
mongoose.disconnect();
});

});
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
server:
build: .
depends_on:
- 'database'
ports:
- '3004:3004'

database:
image: mongo:latest
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"start": "nodemon server/index.js",
"docker": "webpack -p && node db/seed.js & node server/index.js",
"build": "webpack -d --watch",
"db:setup": "node db/seed.js",
"lint": "eslint . --ext .js, .jsx",
Expand Down