File tree Expand file tree Collapse file tree 11 files changed +218
-141
lines changed Expand file tree Collapse file tree 11 files changed +218
-141
lines changed Original file line number Diff line number Diff line change
1
+ .git
2
+ .gitignore
3
+ README.md
4
+ docker-compose.yml
5
+ node_modules /
6
+ dist /
7
+ test /
Original file line number Diff line number Diff line change
1
+ FROM node:carbon-alpine
2
+ WORKDIR /www
3
+ COPY . /www
4
+ RUN npm install
Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ PORT=8888
60
60
61
61
### Run
62
62
63
+ > Node.js & Docker support. ** You need to create a ` .env ` file as above** .
64
+
63
65
### Node.js
64
66
65
67
Beacuse of using Koa2, ` Node.js >= v7.6.0 ` is needed.
@@ -74,7 +76,7 @@ open browser: `localhost:8080`
74
76
75
77
#### Production:
76
78
77
- ` npm run build ` and then ` npm run server `
79
+ ` npm run start `
78
80
79
81
open browser: ` localhost:8889 `
80
82
@@ -84,6 +86,16 @@ open browser: `localhost:8889`
84
86
85
87
` npm run test ` and find the coverage report in the ` coverage/lcov/index.html `
86
88
89
+ ### Docker
90
+
91
+ ` docker-compose build ` && ` docker-compose up `
92
+
93
+ > mysql in docker use 3306 port inside & outside.
94
+
95
+ open browser: ` localhost:8889 `
96
+
97
+ > tips: login password is 123
98
+
87
99
## License
88
100
89
101
[ MIT] ( http://opensource.org/licenses/MIT )
Original file line number Diff line number Diff line change
1
+ version : " 3"
2
+
3
+ volumes :
4
+ mysqlstorage :
5
+
6
+ services :
7
+ node :
8
+ build :
9
+ context : .
10
+ dockerfile : Dockerfile
11
+ env_file :
12
+ - ./.env
13
+ volumes :
14
+ - ./:/www
15
+ ports :
16
+ - ${PORT}:${PORT}
17
+ command : " npm run start"
18
+ environment :
19
+ DB_URL : mysql
20
+ links :
21
+ - mysql
22
+ depends_on :
23
+ - mysql
24
+
25
+ mysql :
26
+ image : ' mysql:5.7'
27
+ env_file :
28
+ - ./.env
29
+ environment :
30
+ MYSQL_ROOT_PASSWORD : ${DB_PASSWORD}
31
+ MYSQL_USER : ${DB_USER}
32
+ build :
33
+ context : .
34
+ dockerfile : mysql.dockerfile
35
+ args :
36
+ MYSQL_ROOT_PASSWORD : ${DB_PASSWORD}
37
+ restart : always
38
+ volumes :
39
+ - mysqlstorage:/data/db
40
+ ports :
41
+ - " 3306:3306"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ mysql -u$MYSQL_USER -p$MYSQL_ROOT_PASSWORD << EOF
3
+ source $WORK_PATH /$FILE_0 ;
4
+ source $WORK_PATH /$FILE_1 ;
Original file line number Diff line number Diff line change
1
+ FROM mysql:5.7
2
+ LABEL maintainer=
"Molunerfinn <[email protected] >"
3
+ ARG MYSQL_ROOT_PASSWORD
4
+ ARG MYSQL_USER
5
+
6
+ ENV MYSQL_ROOT_PASSWORD $MYSQL_ROOT_PASSWORD
7
+ ENV MYSQL_USER $MYSQL_USER
8
+ ENV WORK_PATH /usr/local/db
9
+ ENV FILE_0 list.sql
10
+ ENV FILE_1 user.sql
11
+ USER root
12
+
13
+ WORKDIR $WORK_PATH/
14
+
15
+ COPY ./sql/*.sql $WORK_PATH/
16
+ COPY ./init_db.sh /docker-entrypoint-initdb.d/init_db.sh
17
+
18
+ RUN chmod a+x /docker-entrypoint-initdb.d/init_db.sh
Original file line number Diff line number Diff line change 10
10
"server" : " nodemon -w app.js -w server server-entry.js" ,
11
11
"test" : " cross-env NODE_ENV=test jest --forceExit --runInBand" ,
12
12
"coverage" : " cat ./coverage/lcov.info | coveralls" ,
13
- "start" : " cross-env NODE_ENV=production pm2 start pm2.json"
13
+ "prod" : " cross-env NODE_ENV=production node server-entry.js" ,
14
+ "start" : " npm run build && npm run prod" ,
15
+ "start:pm2" : " cross-env NODE_ENV=production pm2 start pm2.json"
14
16
},
15
17
"dependencies" : {
16
18
"axios" : " ^0.15.3" ,
31
33
"stylus-loader" : " ^2.4.0" ,
32
34
"supertest" : " ^3.0.0" ,
33
35
"vue" : " 2.5.2" ,
34
- "vue-jest" : " ^1.0.3" ,
35
36
"vue-router" : " ^2.3.1"
36
37
},
37
38
"devDependencies" : {
39
+ "@vue/test-utils" : " ^1.0.0-beta.12" ,
38
40
"autoprefixer" : " ^7.1.2" ,
39
41
"babel-core" : " ^6.22.1" ,
40
42
"babel-eslint" : " ^7.1.1" ,
79
81
"semver" : " ^5.3.0" ,
80
82
"shelljs" : " ^0.7.6" ,
81
83
"url-loader" : " ^0.5.8" ,
84
+ "vue-jest" : " ^2.3.0" ,
82
85
"vue-loader" : " ^13.3.0" ,
86
+ "vue-server-renderer" : " ^2.5.16" ,
83
87
"vue-style-loader" : " ^3.0.1" ,
84
88
"vue-template-compiler" : " 2.5.2" ,
85
- "vue-test-utils" : " ^1.0.0-beta.4" ,
86
89
"webpack" : " ^3.6.0" ,
87
90
"webpack-bundle-analyzer" : " ^2.9.0" ,
88
91
"webpack-dev-middleware" : " ^1.12.0" ,
Original file line number Diff line number Diff line change 1
1
import '../../env'
2
2
import Sequelize from 'sequelize'
3
3
4
- const Todolist = new Sequelize ( `mysql://${ process . env . DB_USER } :${ process . env . DB_PASSWORD } @localhost/todolist` , {
4
+ const Todolist = new Sequelize ( `mysql://${ process . env . DB_USER } :${ process . env . DB_PASSWORD } @${ process . env . DB_URL || ' localhost' } /todolist` , {
5
5
define : {
6
6
timestamps : false // 取消Sequelzie自动给数据表加入时间戳(createdAt以及updatedAt)
7
7
}
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
2
import elementUI from 'element-ui'
3
- import { mount } from 'vue- test-utils'
3
+ import { mount } from '@ vue/ test-utils'
4
4
import Login from '../../src/components/Login.vue'
5
5
import axios from 'axios'
6
6
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
2
import elementUI from 'element-ui'
3
- import { mount } from 'vue- test-utils'
3
+ import { mount } from '@ vue/ test-utils'
4
4
import Todolist from '../../src/components/Todolist.vue'
5
5
import axios from 'axios'
6
6
You can’t perform that action at this time.
0 commit comments