Skip to content

Commit

Permalink
Merge 85a50d5 into 867d0d5
Browse files Browse the repository at this point in the history
  • Loading branch information
JustalK committed Nov 15, 2020
2 parents 867d0d5 + 85a50d5 commit 463e0fd
Show file tree
Hide file tree
Showing 179 changed files with 1,656 additions and 288 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ coverage
.nyc_output
index.html
docs
cypress
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- 15
- 14
- 12
services:
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:15

# Create app directory
WORKDIR /home/justalk/portfolio

COPY package*.json ./

USER justalk

RUN npm install

COPY --chown=justalk:justalk . .

EXPOSE 8080
RUN npm run server
14 changes: 12 additions & 2 deletions config/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
require('dotenv').config({ path: './env/.env.development' });
const mode = process.env.NODE_ENV !== undefined ? process.env.NODE_ENV : 'production';
require('dotenv').config({ path: './env/.env.' + mode });
const base_url = process.env.PROTOCOL + '://' + process.env.HOST + ':' + process.env.PORT;


module.exports = {
entry: {
Expand All @@ -16,6 +20,11 @@ module.exports = {
'vue$': 'vue/dist/vue.esm.js'
}
},
output: {
filename: 'index.js',
path: path.resolve(__dirname+'/../' + process.env.FOLDER + '/'),
publicPath: base_url + '/'
},
plugins: [
new VueLoaderPlugin(),
new ESLintPlugin({
Expand All @@ -32,7 +41,7 @@ module.exports = {
}),
new HtmlWebpackPlugin({
title: 'Custom template',
filename: '../index.html',
filename: '../' + process.env.FOLDER + '/index.html',
template: 'src/pages/index.html'
}),
new StyleLintPlugin({
Expand All @@ -46,6 +55,7 @@ module.exports = {
patterns: [
{ from: 'src/assets/imgs', to: 'assets/imgs' },
{ from: 'src/assets/fonts', to: 'assets/fonts' },
{ from: 'src/assets/favicon', to: 'assets/favicon' }
],
}),
new webpack.DefinePlugin({
Expand Down
5 changes: 0 additions & 5 deletions config/dev.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
const { merge } = require('webpack-merge');
const baseConfig = require('./base.config.js');
const path = require('path');

module.exports = merge(baseConfig, {
output: {
filename: 'index.js',
path: path.resolve(__dirname+'/../', 'dev')
},
module: {
rules: [ {
test: /\.(png|jpg|jpeg|gif)$/,
Expand Down
5 changes: 0 additions & 5 deletions config/prod.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
const { merge } = require('webpack-merge');
const baseConfig = require('./base.config.js');
const path = require('path');

module.exports = merge(baseConfig, {
output: {
filename: 'index.js',
path: path.resolve(__dirname + '/../', 'build')
},
module: {
rules: [ {
test: /\.html$/,
Expand Down
5 changes: 5 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrationFolder": "./tests/e2e",
"video": false,
"screenshotOnRunFailure": false
}
55 changes: 20 additions & 35 deletions dev/index.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3.8"
services:
mongodb:
image: mongo:latest
volumes:
- mongodb_data_container:/data/db
ports:
- "27018:27018"
command: mongod --port 27018
networks:
- app-network
app:
container_name: portfolio
restart: always
build: .
ports:
- "8080:8080"
command: bash -c "/usr/wait-for-it.sh --timeout=15 mongodb:27018 && npm run seed-docker && npm run build && npm run server-docker"
depends_on:
- mongodb
links:
- mongodb
networks:
- app-network

networks:
app-network:
driver: bridge

volumes:
mongodb_data_container:
15 changes: 15 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:15

# Create app directory
WORKDIR /home/justalk/portfolio

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

COPY scripts/wait-for-it.sh /usr/wait-for-it.sh
RUN chmod +x /usr/wait-for-it.sh
1 change: 1 addition & 0 deletions env/.env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NODE_ENV=development
FOLDER=dev

API_NAME=JUSTALK-SERVER
HOST=localhost
Expand Down
18 changes: 18 additions & 0 deletions env/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
NODE_ENV=development
FOLDER=dev

API_NAME=JUSTALK-SERVER
HOST=172.27.0.3
PORT=8080
PROTOCOL=http

DB_NAME=justalk
DB_URI_DATA=mongodb://mongodb:27018/
DB_URI_LOG=mongodb://mongodb:27018/logs
DB_USER_DATA=
DB_PASS_DATA=
DB_HOST_LOG=localhost
DB_PORT_LOG=27017
DB_NAME_LOG=logs
DB_USER_LOG=
DB_PASS_LOG=
3 changes: 2 additions & 1 deletion env/.env.production
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
NODE_ENV=production
FOLDER=build

API_NAME=JUSTALK-SERVER
HOST=localhost
PORT=8080
BASE_URL=http://localhost:8080/
PROTOCOL=http

DB_NAME=justalk
DB_URI_DATA=mongodb://localhost:27017/
Expand Down
18 changes: 18 additions & 0 deletions env/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
NODE_ENV=production
FOLDER=dev

API_NAME=JUSTALK-SERVER
HOST=localhost
PORT=8080
PROTOCOL=http

DB_NAME=justalk
DB_URI_DATA=mongodb://localhost:27017/
DB_URI_LOG=mongodb://localhost:27017/logs
DB_USER_DATA=
DB_PASS_DATA=
DB_HOST_LOG=localhost
DB_PORT_LOG=27017
DB_NAME_LOG=logs
DB_USER_LOG=
DB_PASS_LOG=
22 changes: 17 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
"main": "server/index.js",
"scripts": {
"seed": "node -e 'require(\"./seeding/seeder.js\").seed()'",
"dev": "webpack --mode development --config config/dev.config.js",
"dev": "export NODE_ENV=development && webpack --mode development --config config/dev.config.js",
"build": "webpack --mode production --config config/prod.config.js",
"watch": "nodemon --watch \"src/\" -x \"npm run dev\"",
"watch-server": "nodemon --exec 'npm run server'",
"start": "node -e 'require(\"./server/index\").start()'",
"test": "nyc --reporter=html --reporter=text ava tests/**/*.js ava tests/**/**/*.js --verbose --timeout=1m",
"coverage": "nyc report --reporter=text-lcov | coveralls"
"watch-server": "export NODE_ENV=development && nodemon --exec 'npm run server'",
"server": "node -e 'require(\"./server/index\").start()'",
"start": "export NODE_ENV=production && npm run seed && npm run build && npm run server",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"cypress-tools": "npx cypress open",
"test": "export NODE_ENV=test && nyc --reporter=html --reporter=text ava tests/server/*.js ava tests/server/**/*.js --verbose --timeout=1m",
"cypress": "cypress run",
"e2e": "start-server-and-test server http://localhost:8080 cypress",
"server-docker": "export NODE_ENV=docker && node -e 'require(\"./server/index\").start()'",
"seed-docker": "export NODE_ENV=docker && npm run seed",
"docker": "sudo docker-compose up --build --force-recreate"
},
"engines": {
"node": ">=12.0"
Expand Down Expand Up @@ -41,6 +48,8 @@
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@testing-library/cypress": "^7.0.1",
"@testing-library/dom": "^7.26.6",
"ava": "^3.13.0",
"babel-core": "*",
"babel-eslint": "^10.1.0",
Expand All @@ -52,6 +61,7 @@
"copy-webpack-plugin": "^6.2.1",
"coveralls": "^3.1.0",
"css-loader": "^5.0.0",
"cypress": "^5.6.0",
"eslint": "^7.12.0",
"eslint-config-es2015": "*",
"eslint-plugin-vue": "^7.1.0",
Expand All @@ -67,11 +77,13 @@
"less-loader": "^7.0.2",
"lqip-loader": "^2.2.1",
"mongo-seeding": "^3.4.1",
"npx": "^10.2.2",
"nyc": "^15.1.0",
"postcss": "^8.1.4",
"postcss-loader": "^4.0.4",
"postcss-preset-env": "^6.7.0",
"prettier": "^2.1.2",
"start-server-and-test": "^1.11.5",
"style-loader": "^2.0.0",
"stylelint": "^13.7.2",
"stylelint-config-standard": "^20.0.0",
Expand Down
14 changes: 4 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,15 @@ I am developing following an easy to understand cycle. This way I am sure to not

![Alt text](documentation/management/cycle.jpg?raw=true "PORTFOLIO-CYCLE")

## Prerequisite

For the project to work properly on your computer, you need to have on your machine :
## Installation

1. A machine with node installed :
https://nodejs.org/en/download/
The easiest and fatest way to install this project is through `docker-compose` with this command :

2. A working Mongo database : https://docs.mongodb.com/manual/installation/
```
MongoDB
npm run docker
```

## Installation

After cloning the project, you can install all the dependencies of the project by running this command at the root of the project :
If you do not have docker on your machine, you will need to have node and a mongodb on your machine, you can install all the dependencies of the project by running this command at the root of the project :
```
$ npm install
```
Expand Down
Loading

0 comments on commit 463e0fd

Please sign in to comment.