Skip to content

Develop #2

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
wants to merge 15 commits 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
6 changes: 4 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
NODE_ENV=development
NODE_ENV_PROD=production
POSTGRES_USER=appuser
POSTGRES_DB=appdb
MYSQL_ROOT_PASSWORD=root
MYSQL_USER=appuser
MYSQL_PASSWORD=appuser
MYSQL_DATABASE=appdb
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified backend/.babelrc
100644 → 100755
Empty file.
Empty file modified backend/.dockerignore
100644 → 100755
Empty file.
Empty file modified backend/.sequelizerc
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions backend/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# production dockerfile
FROM node:5.10
FROM mhart/alpine-node:latest

# add code
COPY . /backend
Expand All @@ -14,4 +14,4 @@ RUN npm i -q && \

#migrate & run
CMD ./node_modules/.bin/sequelize db:migrate && \
npm run serve
npm run serve
8 changes: 4 additions & 4 deletions backend/config/default.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"database": {
"username": "appuser",
"database": "appdb",
"password": null,
"password": "appuser",
"host": "db",
"port": 5432,
"dialect": "postgres"
"port": 3306,
"dialect": "mysql"
},

"loggers": {
Expand All @@ -34,4 +34,4 @@
}
]
}
}
}
Empty file modified backend/config/development.json
100644 → 100755
Empty file.
Empty file modified backend/config/production.json
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions backend/config/test.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"password": null,
"host": "dbtest",
"port": 5432,
"dialect": "postgres"
"dialect": "mysql"
}
}
}
4 changes: 3 additions & 1 deletion backend/lib/api/index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import express from 'express';
import notes from './notes';
import users from './users';

const router = express.Router();
router.use(notes);
export default router;
router.use(users);
export default router;
2 changes: 1 addition & 1 deletion backend/lib/api/notes.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ router.post('/notes/', function(req, res) {
});
})

export default router;
export default router;
33 changes: 33 additions & 0 deletions backend/lib/api/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

import express from 'express';
import models from '../models';
import logger from '../logger';

const router = express.Router();

// list
router.get('/users/', function(req, res){
models.users.findAll()
.then(function(users){
res.json(users.map(user => user.toJSON()));
}).catch(function(e){
logger.error('error fetching users', e);
res.status(500).json({});
});
});
// create
router.post('/users/', function(req, res){
logger.info('creating user', JSON.stringify(req.body));

models.users.create(req.body)
.then(function(user){
res.status(201).json(user.toJSON());
}).catch(function(e){
logger.error('error creating user', e);
res.status(500).json();
});
});
// delete

export default router;
Empty file modified backend/lib/app.js
100644 → 100755
Empty file.
Empty file modified backend/lib/conf.js
100644 → 100755
Empty file.
Empty file modified backend/lib/index.js
100644 → 100755
Empty file.
Empty file modified backend/lib/logger.js
100644 → 100755
Empty file.
Empty file modified backend/lib/migrations/20160425105021-create-note.js
100644 → 100755
Empty file.
33 changes: 33 additions & 0 deletions backend/lib/migrations/20170912140434-create-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.createTable('users', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
first_name: {
type: Sequelize.STRING
},
last_name: {
type: Sequelize.STRING
},
email: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable('users');
}
};
Empty file modified backend/lib/models/Note.js
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions backend/lib/models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';
module.exports = function(sequelize, DataTypes) {
var Users = sequelize.define('users', {
first_name: DataTypes.STRING,
last_name: DataTypes.STRING,
email: DataTypes.STRING
}, {
classMethods: {
associate: function(models) {
// associations can be defined here
}
}
});

return Users;
};
Empty file modified backend/lib/models/index.js
100644 → 100755
Empty file.
Empty file modified backend/nightwatch.json
100644 → 100755
Empty file.
7 changes: 4 additions & 3 deletions backend/package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
"body-parser": "^1.17.1",
"express": "^4.15.2",
"fs-extra": "^2.1.2",
"minimatch": "^3.0.4",
"mysql2": "^1.4.2",
"nconf": "^0.8.4",
"pg": "^6.1.4",
"pug": "^2.0.0-beta11",
"sequelize": "^3.30.2",
"sequelize-cli": "^2.6.0",
"sequelize": "^4.8.3",
"sequelize-cli": "^2.8.0",
"winston": "^2.3.1"
},
"devDependencies": {
Expand Down
Empty file modified backend/tests/globals.js
100644 → 100755
Empty file.
Empty file modified backend/tests/specs/notes.js
100644 → 100755
Empty file.
Empty file modified backend/views/index.pug
100644 → 100755
Empty file.
Empty file modified backend/views/loader.html
100644 → 100755
Empty file.
Empty file modified backups/.gitkeep
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions bin/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
source bin/env.sh

BACKUP_FILE=django$1_$(date +'%Y_%m_%dT%H_%M_%S').bak
dcprod -f docker-compose.db.yml run --rm dbclient bash -c 'pg_dump -Fc -h db -U $POSTGRES_USER -d $POSTGRES_DB -f /backups/'"$BACKUP_FILE"
echo "backup $BACKUP_FILE created"
dcprod -f docker-compose.db.yml run --rm dbclient bash -c 'pg_dump -Fc -h db -U $MYSQL_USER -d $MYSQL_DATABASE -f /backups/'"$BACKUP_FILE"
echo "backup $BACKUP_FILE created"
6 changes: 3 additions & 3 deletions bin/init_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ if [ $(docker-compose -f docker-compose.yml -f $DOCKER_INIT_DB_CONFIG ps | grep
echo "initializing database"
docker-compose -f docker-compose.yml -f $DOCKER_INIT_DB_CONFIG up -d db
DB_CONTAINER_ID=$(docker-compose -f docker-compose.yml -f $DOCKER_INIT_DB_CONFIG ps -q db)
for i in {30..0}; do
echo "waiting for postgres to finish initializing..."
if [ $(docker logs $DB_CONTAINER_ID 2>&1 | grep "database system is ready to accept connections" | wc -l) == 1 ]; then
for i in {45..0}; do
echo "waiting for mysql to finish initializing..."
if [ $(docker logs $DB_CONTAINER_ID 2>&1 | grep "ready for connections" | wc -l) == 1 ]; then
docker-compose -f docker-compose.yml -f $DOCKER_INIT_DB_CONFIG stop db
echo "db initialized"
exit 0
Expand Down
6 changes: 6 additions & 0 deletions bin/mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# open mysql session to production db

source bin/env.sh

dcprod -f docker-compose.db.yml run --rm dbclient bash -c 'mysql --user $MYSQL_USER --password $MYSQL_PASSWORD $MYSQL_DATABASE'
6 changes: 0 additions & 6 deletions bin/psql.sh

This file was deleted.

4 changes: 2 additions & 2 deletions bin/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ if [ $(docker-compose -f docker-compose.yml -f $DOCKER_CONFIG_PROD -f docker-com
fi

echo "restoring database..."
dcprod -f docker-compose.db.yml run --rm dbclient bash -c 'dropdb -h db -U $POSTGRES_USER $POSTGRES_DB && createdb -h db -U $POSTGRES_USER -O $POSTGRES_USER $POSTGRES_DB && pg_restore -Fc -h db -U $POSTGRES_USER -d $POSTGRES_DB '"$BACKUP_FILE"
echo "restore complete"
dcprod -f docker-compose.db.yml run --rm dbclient bash -c 'dropdb -h db -U $MYSQL_USER $MYSQL_DATABASE && createdb -h db -U $MYSQL_USER -O $MYSQL_USER $MYSQL_DATABASE && pg_restore -Fc -h db -U $MYSQL_USER -d $MYSQL_DATABASE '"$BACKUP_FILE"
echo "restore complete"
Empty file modified bin/sequelize_prod.sh
100644 → 100755
Empty file.
20 changes: 11 additions & 9 deletions docker-compose.db.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: '2'
services:
dbclient:
image: postgres:9.6
depends_on:
- db
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
volumes:
- "./backups:/backups"
dbclient:
image: mysql:5.7.19
depends_on:
- db
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
volumes:
- "./backups:/backups"
48 changes: 24 additions & 24 deletions docker-compose.development.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
version: '2'
services:
db:
ports:
- "9432:5432"
frontend:
image: node:7.7
working_dir: /frontend
command: npm run develop
volumes:
- ./frontend:/frontend
ports:
- "3000:3000"
backend:
image: node:7.7
working_dir: /backend
command: npm run develop
volumes:
- ./backend:/backend
- ./backend/media:/media
ports:
- "8000:8000"
environment:
NODE_ENV: ${NODE_ENV}
depends_on:
- db
db:
ports:
- "3306:3306"
frontend:
image: mhart/alpine-node:latest
working_dir: /frontend
command: npm run develop
volumes:
- ./frontend:/frontend
ports:
- "3000:3000"
backend:
image: mhart/alpine-node:latest
working_dir: /backend
command: npm run develop
volumes:
- ./backend:/backend
- ./backend/media:/media
ports:
- "8000:8000"
environment:
NODE_ENV: ${NODE_ENV}
depends_on:
- db
Empty file modified docker-compose.production.yml
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions docker-compose.test.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ services:
dbtest:
image: postgres:9.5
environment:
POSTGRES_DB: testdb
POSTGRES_USER: testuser
MYSQL_DATABASE: testdb
MYSQL_USER: testuser
selenium:
image: selenium/standalone-chrome-debug:2.53.0
ports:
Expand All @@ -21,4 +21,4 @@ services:
NODE_ENV: test
depends_on:
- dbtest
- selenium
- selenium
26 changes: 15 additions & 11 deletions docker-compose.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
version: '2'
services:
dbdata:
image: postgres:9.6
command: "true"

db:
image: postgres:9.6
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
volumes_from:
- dbdata
dbdata:
image: mysql:5.7.19
command: "true"
volumes:
- /media/data/db_data/mysql:/var/lib/mysql
db:
image: mysql:5.7.19
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
volumes_from:
- dbdata

Empty file modified frontend/.babelrc
100644 → 100755
Empty file.
Empty file modified frontend/.eslintrc
100644 → 100755
Empty file.
Empty file modified frontend/dist/.gitkeep
100644 → 100755
Empty file.
Empty file modified frontend/package.json
100644 → 100755
Empty file.
Empty file modified frontend/src/images/hamster.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified frontend/src/js/actions/notes.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/actions/types.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/components/notes/list.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/containers/app-container.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/containers/home-container.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/containers/notes-container.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/index.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/reducers/index.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/reducers/notes.js
100644 → 100755
Empty file.
Empty file modified frontend/src/js/store.js
100644 → 100755
Empty file.
Empty file modified frontend/src/style/index.styl
100644 → 100755
Empty file.
Empty file modified frontend/src/style/notes.styl
100644 → 100755
Empty file.
Empty file modified frontend/webpack/dev-server.js
100644 → 100755
Empty file.
Empty file modified frontend/webpack/webpack.config.base.js
100644 → 100755
Empty file.
Empty file modified frontend/webpack/webpack.config.development.js
100644 → 100755
Empty file.
Empty file modified frontend/webpack/webpack.config.production.js
100644 → 100755
Empty file.
Empty file modified nginx/Dockerfile
100644 → 100755
Empty file.
Empty file modified nginx/nginx_nossl.conf
100644 → 100755
Empty file.
Empty file modified nginx/nginx_ssl.conf
100644 → 100755
Empty file.
Empty file modified nginx/ssl/.gitkeep
100644 → 100755
Empty file.