Skip to content

Commit ee82bd8

Browse files
thonatosJacksonTian
authored andcommitted
fix: update docs & dockerfile for building assets (#95)
* fix: build assets before * docs: config env & build assets * docs: build assets for prod * chore: add config for docker-compose * docs: enable mini assets for prod * docs: use config.${env}.js
1 parent 625c015 commit ee82bd8

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RUN npm i --production
1212

1313
COPY . /usr/src/app
1414

15+
RUN npm run assets
16+
1517
EXPOSE 7001
1618

1719
CMD npm run docker

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ $ open http://localhost:7001/
5151

5252
### Deploy
5353

54+
```js
55+
// {app_root}/config/config.prod.js
56+
57+
exports.mini_assets = true;
58+
59+
exports.alinode = {
60+
// 从 `Node.js 性能平台` 获取对应的接入参数
61+
appid: process.env.EGG_ALINODE_APPID || '',
62+
secret: process.env.EGG_ALINODE_SECRET || '',
63+
};
64+
```
65+
5466
```bash
67+
$ npm i --production
68+
$ npm run assets
5569
$ npm start
5670
$ npm stop
5771
```

config/config.default.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ module.exports = appInfo => {
3434
config.allow_sign_up = true;
3535

3636
// cdn host,如 http://cnodejs.qiniudn.com
37-
config.site_static_host = ''; // 静态文件存储域名
37+
config.site_static_host = process.env.EGG_SITE_STATIC_HOST || ''; // 静态文件存储域名
38+
39+
config.mini_assets = process.env.EGG_MINI_ASSETS || false;
3840

3941
// 版块
4042
config.tabs = [[ 'share', '分享' ], [ 'ask', '问答' ], [ 'job', '招聘' ]];

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ services:
1515
- EGG_REDIS_PORT=6379
1616
- EGG_REDIS_PASSWORD=egg_cnode
1717
- EGG_MONGODB_URL=mongodb://egg_cnode:egg_cnode@mongodb:27017/egg_cnode
18+
- EGG_MINI_ASSETS=true
1819
- EGG_PASSPORT_GITHUB_CLIENT_ID=test
1920
- EGG_PASSPORT_GITHUB_CLIENT_SECRET=test
21+
# - EGG_SITE_STATIC_HOST=${EGG_SITE_STATIC_HOST}
2022
- EGG_ALINODE_APPID=appid
2123
- EGG_ALINODE_SECRET=secret
2224
depends_on:

tutorials/Docker.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,20 @@ docker-compose -f docker-compose.dev.yml down -v
7272

7373
**Develop**:
7474

75-
```
75+
```bash
76+
export EGG_REDIS_PASSWORD=egg_cnode
77+
export EGG_MONGODB_URL=mongodb://egg_cnode:[email protected]:27017/egg_cnode
78+
export EGG_PASSPORT_GITHUB_CLIENT_ID=${id}
79+
export EGG_PASSPORT_GITHUB_CLIENT_SECRET=${secret}
80+
81+
npm i
7682
npm run dev
7783
```
7884

7985
## Deploy
8086

87+
Modify docker-compose.yml
88+
8189
**Run / Stop**
8290

8391
```bash

0 commit comments

Comments
 (0)