Skip to content

Commit d89afbd

Browse files
thonatosJacksonTian
authored andcommitted
docs: add docker support tutorial (#92)
* docs: move docker-support out from readme.md * fix: use image from docker hub * fix: last reply time bug (#91) closes #90 * docs: move docker-support out from readme.md * fix: use image from docker hub
1 parent 551e1e7 commit d89afbd

File tree

4 files changed

+103
-77
lines changed

4 files changed

+103
-77
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ WORKDIR /usr/src/app
66

77
COPY package.json /usr/src/app/
88

9-
# RUN npm i --production
9+
RUN npm i --production
1010

11-
RUN npm i --production --registry=https://registry.npm.taobao.org
11+
# RUN npm i --production --registry=https://registry.npm.taobao.org
1212

1313
COPY . /usr/src/app
1414

README.md

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -49,88 +49,21 @@ $ npm run dev
4949
$ open http://localhost:7001/
5050
```
5151

52-
#### Develop with docker
53-
Setup redis / mongodb, requirements:
54-
55-
- docker
56-
- docker-compose
57-
58-
```bash
59-
# start
60-
docker-compose -f docker-compose.dev.yml up
61-
62-
# stop
63-
docker-compose -f docker-compose.dev.yml down
64-
65-
# remove volume/cache
66-
docker-compose -f docker-compose.dev.yml down -v
67-
```
68-
6952
### Deploy
7053

7154
```bash
7255
$ npm start
7356
$ npm stop
7457
```
7558

76-
#### Deploy with docker
77-
Setup redis / mongodb / egg-cnode, requirements:
78-
79-
- docker
80-
- docker-compose
81-
82-
**Modify Github Id/Secret**
83-
84-
```yml
85-
version: '3'
86-
services:
87-
cnode:
88-
environment:
89-
- EGG_PASSPORT_GITHUB_CLIENT_ID=test
90-
- EGG_PASSPORT_GITHUB_CLIENT_SECRET=test
91-
```
92-
93-
**Modify Alinode AppId/Secret**
94-
95-
```yml
96-
version: '3'
97-
services:
98-
cnode:
99-
environment:
100-
- EGG_ALINODE_APPID=appid
101-
- EGG_ALINODE_SECRET=secret
102-
```
103-
104-
> to disable alinode, modify config/plugin.prod.js
105-
106-
**Change Port**
107-
108-
```yml
109-
version: '3'
110-
services:
111-
cnode:
112-
ports:
113-
- ${PORT}:7001
114-
```
115-
116-
**Run / Stop**
117-
118-
```bash
119-
# start
120-
docker-compose up -d
121-
122-
# stop
123-
docker-compose down
124-
125-
# remove volume/cache
126-
docker-compose down -v
127-
```
128-
12959
### npm scripts
13060

13161
- Use `npm run lint` to check code style.
13262
- Use `npm test` to run unit test.
13363
- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail.
13464

65+
### Tutorials
66+
67+
- [Develop / Deploy with Docker](tutorials/Docker.md)
13568

13669
[egg]: https://eggjs.org

docker-compose.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
version: '3'
22
services:
33
cnode:
4-
build:
5-
context: .
6-
dockerfile: Dockerfile
7-
# args:
8-
# - env=value
4+
# build:
5+
# context: .
6+
# dockerfile: Dockerfile
7+
# args:
8+
# - env=value
9+
image: cnode/egg-cnode:latest
910
environment:
1011
- NODE_ENV=production
1112
- EGG_SERVER_ENV=prod

tutorials/Docker.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Docker
2+
3+
[![Docker Automated build][docker-build-image]][docker-build-url] [![Docker Stars][docker-star-image]][docker-star-url] [![Docker pulls][docker-pull-image]][docker-pull-url]
4+
5+
[docker-build-image]: https://img.shields.io/docker/automated/cnode/egg-cnode.svg
6+
[docker-build-url]: https://github.com/cnode/egg-cnode/
7+
[docker-star-image]: https://img.shields.io/docker/stars/cnode/egg-cnode.svg
8+
[docker-star-url]: https://registry.hub.docker.com/v2/repositories/cnode/egg-cnode/stars/count/
9+
[docker-pull-image]: https://img.shields.io/docker/pulls/cnode/egg-cnode.svg
10+
[docker-pull-url]: https://registry.hub.docker.com/v2/repositories/cnode/egg-cnode/
11+
12+
## Requirements
13+
14+
- docker
15+
- docker-compose
16+
17+
## Config
18+
19+
**Compose**
20+
21+
- docker-compose.dev.yml
22+
- docker-compose.yml
23+
24+
**Modify Github Id/Secret**
25+
26+
```yml
27+
version: '3'
28+
services:
29+
cnode:
30+
environment:
31+
- EGG_PASSPORT_GITHUB_CLIENT_ID=test
32+
- EGG_PASSPORT_GITHUB_CLIENT_SECRET=test
33+
```
34+
35+
**Modify Alinode AppId/Secret**
36+
37+
```yml
38+
version: '3'
39+
services:
40+
cnode:
41+
environment:
42+
- EGG_ALINODE_APPID=appid
43+
- EGG_ALINODE_SECRET=secret
44+
```
45+
46+
> to disable alinode, modify config/plugin.prod.js
47+
48+
**Change Port**
49+
50+
```yml
51+
version: '3'
52+
services:
53+
cnode:
54+
ports:
55+
- ${PORT}:7001
56+
```
57+
58+
## Develop
59+
60+
Setup redis / mongodb / egg-cnode
61+
62+
```bash
63+
# start
64+
docker-compose -f docker-compose.dev.yml up
65+
66+
# stop
67+
docker-compose -f docker-compose.dev.yml down
68+
69+
# remove volume/cache
70+
docker-compose -f docker-compose.dev.yml down -v
71+
```
72+
73+
**Develop**:
74+
75+
```
76+
npm run dev
77+
```
78+
79+
## Deploy
80+
81+
**Run / Stop**
82+
83+
```bash
84+
# start
85+
docker-compose up -d
86+
87+
# stop
88+
docker-compose down
89+
90+
# remove volume/cache
91+
docker-compose down -v
92+
```

0 commit comments

Comments
 (0)