File tree Expand file tree Collapse file tree 11 files changed +182
-59
lines changed Expand file tree Collapse file tree 11 files changed +182
-59
lines changed Original file line number Diff line number Diff line change
1
+ node_modules /
2
+ .git /
Original file line number Diff line number Diff line change 1
1
coverage
2
- app /public /
2
+ app /public /
Original file line number Diff line number Diff line change
1
+ FROM node:8.9.4-alpine
2
+
3
+ RUN mkdir -p /usr/src/app
4
+
5
+ WORKDIR /usr/src/app
6
+
7
+ COPY package.json /usr/src/app/
8
+
9
+ # RUN npm i --production
10
+
11
+ RUN npm i --production --registry=https://registry.npm.taobao.org
12
+
13
+ COPY . /usr/src/app
14
+
15
+ EXPOSE 7001
16
+
17
+ CMD npm run docker
Original file line number Diff line number Diff line change @@ -28,6 +28,23 @@ $ npm run dev
28
28
$ open http://localhost:7001/
29
29
```
30
30
31
+ #### Develop with docker
32
+ Setup redis / mongodb, requirements:
33
+
34
+ - docker
35
+ - docker-compose
36
+
37
+ ``` bash
38
+ # start
39
+ docker-compose -f docker-compose.dev.yml up
40
+
41
+ # stop
42
+ docker-compose -f docker-compose.dev.yml down
43
+
44
+ # remove volume/cache
45
+ docker-compose -f docker-compose.dev.yml down -v
46
+ ```
47
+
31
48
### Deploy
32
49
33
50
``` bash
Original file line number Diff line number Diff line change @@ -72,5 +72,36 @@ module.exports = appInfo => {
72
72
ADMIN_USER : true ,
73
73
} ;
74
74
75
+ // database
76
+ config . redis = {
77
+ client : {
78
+ host : process . env . EGG_REDIS_HOST || '127.0.0.1' ,
79
+ port : process . env . EGG_REDIS_PORT || 6379 ,
80
+ password : process . env . EGG_REDIS_PASSWORD || '' ,
81
+ db : process . env . EGG_REDIS_DB || '0' ,
82
+ } ,
83
+ } ;
84
+
85
+ /**
86
+ * @see http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection
87
+ */
88
+ config . mongoose = {
89
+ url : process . env . EGG_MONGODB_URL || 'mongodb://127.0.0.1:27017/egg_cnode' ,
90
+ options : {
91
+ server : { poolSize : 20 } ,
92
+ } ,
93
+ } ;
94
+
95
+ // passport
96
+ config . passportGithub = {
97
+ key : process . env . EGG_PASSPORT_GITHUB_CLIENT_ID || 'test' ,
98
+ secret : process . env . EGG_PASSPORT_GITHUB_CLIENT_SECRET || 'test' ,
99
+ } ;
100
+
101
+ config . passportLocal = {
102
+ usernameField : 'name' ,
103
+ passwordField : 'pass' ,
104
+ } ;
105
+
75
106
return config ;
76
107
} ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+ services :
3
+ redis :
4
+ image : redis:3.2-alpine
5
+ command : redis-server --appendonly yes --requirepass egg_cnode
6
+ volumes :
7
+ - egg-redis:/data
8
+ networks :
9
+ - docker_cnode
10
+ ports :
11
+ - 6379:6379
12
+
13
+ mongodb :
14
+ image : mongo:3.2
15
+ restart : always
16
+ environment :
17
+ - MONGO_INITDB_ROOT_USERNAME=root
18
+ - MONGO_INITDB_ROOT_PASSWORD=mongodb
19
+ - MONGO_INITDB_DATABASE=egg_cnode
20
+ volumes :
21
+ - egg-mongo:/data/db
22
+ - ./init.d/mongo/:/docker-entrypoint-initdb.d/
23
+ networks :
24
+ - docker_cnode
25
+ ports :
26
+ - 27017:27017
27
+
28
+ volumes :
29
+ egg-mongo :
30
+ egg-redis :
31
+
32
+ networks :
33
+ docker_cnode :
34
+ driver : bridge
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+ services :
3
+ cnode :
4
+ build :
5
+ context : .
6
+ dockerfile : Dockerfile
7
+ # args:
8
+ # - env=value
9
+ environment :
10
+ - NODE_ENV=production
11
+ - EGG_SERVER_ENV=prod
12
+ - EGG_REDIS_DB=0
13
+ - EGG_REDIS_HOST=redis
14
+ - EGG_REDIS_PORT=6379
15
+ - EGG_REDIS_PASSWORD=egg_cnode
16
+ - EGG_MONGODB_URL=mongodb://egg_cnode:egg_cnode@mongodb:27017/egg_cnode
17
+ - EGG_PASSPORT_GITHUB_CLIENT_ID=test
18
+ - EGG_PASSPORT_GITHUB_CLIENT_SECRET=test
19
+ depends_on :
20
+ - redis
21
+ - mongodb
22
+ networks :
23
+ - docker_cnode
24
+ ports :
25
+ - 7001:7001
26
+
27
+ redis :
28
+ image : redis:3.2-alpine
29
+ command : redis-server --appendonly yes --requirepass egg_cnode
30
+ volumes :
31
+ - egg-redis:/data
32
+ networks :
33
+ - docker_cnode
34
+ ports :
35
+ - 6379:6379
36
+
37
+ mongodb :
38
+ image : mongo:3.2
39
+ restart : always
40
+ environment :
41
+ - MONGO_INITDB_ROOT_USERNAME=root
42
+ - MONGO_INITDB_ROOT_PASSWORD=mongodb
43
+ - MONGO_INITDB_DATABASE=egg_cnode
44
+ volumes :
45
+ - egg-mongo:/data/db
46
+ - ./init.d/mongo:/docker-entrypoint-initdb.d
47
+ networks :
48
+ - docker_cnode
49
+ ports :
50
+ - 27017:27017
51
+
52
+ volumes :
53
+ egg-mongo :
54
+ egg-redis :
55
+
56
+ networks :
57
+ docker_cnode :
58
+ driver : bridge
Original file line number Diff line number Diff line change
1
+ /* eslint-disable */
2
+
3
+ /**
4
+ * 1. create custom user
5
+ * 2. create collection (Before MongoDB can save your new database, a collection name must also be specified at the time of creation.)
6
+ */
7
+ db . createUser ( {
8
+ user : 'egg_cnode' ,
9
+ pwd : 'egg_cnode' ,
10
+ roles : [
11
+ {
12
+ role : 'readWrite' ,
13
+ db : 'egg_cnode'
14
+ }
15
+ ]
16
+ } )
17
+
18
+ db . egg_cnode . insert ( {
19
+ egg_cnode : 'egg-cnode'
20
+ } )
You can’t perform that action at this time.
0 commit comments