Skip to content

Commit dabeee5

Browse files
committed
fix: revert docker deploy doc
1 parent 83c29dd commit dabeee5

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM node:8-alpine
2+
3+
WORKDIR /appops
4+
5+
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
6+
7+
RUN apk update && apk upgrade && \
8+
apk add --no-cache bash git openssh
9+
10+
RUN npm config set registry https://registry.npm.taobao.org
11+
12+
RUN npm install nej -g
13+
14+
COPY . /appops
15+
16+
RUN npm install
17+
18+
RUN npm run build
19+
20+
RUN node -e "c=require('./server/config/online.js');c.ip.disabled=true;c.mysql.host='mysql';c.redis.host='redis';c.mongodb.url=c.mongodb.url.replace('127.0.0.1', 'mongodb');console.log('module.exports =' + JSON.stringify(c))" > config.js
21+
RUN cp config.js ./server/config/online.js
22+
23+
CMD [ "node", "bin/server.js", "start", "-m", "online" ]

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@
3131
- [更新记录](#更新记录)
3232

3333
## 部署方式
34-
### 安装服务器软件
34+
### 部署方式一:Docker 部署
35+
36+
因为有服务依赖,所以需要做容器编排,如果你使用的是 [docker-compose](https://docs.docker.com/compose/),可以直接通过 `docker-compose up -d` 部署,默认服务运行在本地 `8082` 端口,你也可以加入 [Caddy](https://caddyserver.com/) 或者 [Nginx](https://www.nginx.com/) 编排用于实际生产环境。
37+
38+
### 部署方式二:普通部署
39+
40+
#### 安装服务器软件
3541

3642
- [Node.js](https://nodejs.org/en/) `>=6.9.2`
3743
> 如果安装完 Node.js 后,没有自动安装 [NPM](https://www.npmjs.com/get-npm),则需要手动安装。
3844
- [Redis](https://redis.io/) `>=2.8`。
3945
- [MySQL](https://www.mysql.com/) `>=5.7.12`,初始化脚本为 [install.sql](./docs/install.sql)
4046
- [MongoDB](https://www.mongodb.com/) `>=3.4`。
4147
42-
### 安装依赖和构建代码
48+
#### 安装依赖和构建代码
4349
在项目根目录依次执行下述命令,并确保没有错误发生:
4450

4551
- `npm install nej -g`
@@ -50,7 +56,7 @@
5056

5157
> 注意,`npm install` 的速度可能比较慢,可以使用淘宝源,比如 `npm install --registry=https://registry.npm.taobao.org`
5258
53-
### 启动应用
59+
#### 启动应用
5460
**部署前,请确认应用的配置是否都填写正确**,比如数据库的连接配置等。配置文件都放在 `server/config` 目录下面,其中 `develop.js``test.js``online.js` 分别为`本地环境``测试环境``线上环境`的配置文件。配置文件中的参数含义应该比较清晰直白,这里就不再展开介绍。然后,运行下述命令可启动应用:
5561

5662
```shell
@@ -59,7 +65,7 @@
5965

6066
默认情况下,应用会运行在 `8082` 端口上,所以如果想将应用绑定到特定域名,一般需要 [Nginx](https://www.nginx.com/) 服务器,[参考配置](./docs/sample.nginx.conf)
6167

62-
### 停止应用
68+
#### 停止应用
6369
```shell
6470
npm stop
6571
```

docker-compose.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3'
2+
services:
3+
nei:
4+
build: .
5+
restart: always
6+
ports:
7+
- 8082:8082
8+
depends_on:
9+
- redis
10+
- mongodb
11+
- mysql
12+
links:
13+
- redis
14+
- mongodb
15+
- mysql
16+
redis:
17+
image: redis:5-alpine
18+
restart: always
19+
mongodb:
20+
image: mongo:3.4
21+
restart: always
22+
volumes:
23+
- ~/.nei/mongodb:/data/db
24+
mysql:
25+
image: mysql:5.7
26+
restart: always
27+
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
28+
volumes:
29+
- ~/.nei/mysql:/var/lib/mysql
30+
- ./docs:/docker-entrypoint-initdb.d
31+
environment:
32+
MYSQL_DATABASE: nei-test
33+
MYSQL_ROOT_PASSWORD: 123456

0 commit comments

Comments
 (0)