docker安装easy-mock
# 本次使用docker-compose安装easy-mock
# 1.安装docker
https://www.runoob.com/docker/ubuntu-docker-install.html 配置阿里云镜像:https://blog.csdn.net/weixin_44533129/article/details/105982254
# 2.安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
1
# 3.添加执行权限
sudo chmod +x /usr/local/bin/docker-compose
# 4.查看是否安装成功
docker-compose version
# 5.创建两个文件docker-compose.yml,production.json
任意选择一个文件夹或者自己创建,在此文件夹创建这两个文件,并分别写入以下内容 docker-compose.yml 注意:根据自己的创建的文件位置,修改注释中文件位置
version: '3'
services:
mongodb:
image: mongo:3.4.1
volumes:
# ./data/db 数据库文件存放地址,根据需要修改为本地地址
- './data/db:/data/db'
networks:
- easy-mock
restart: always
redis:
image: redis:4.0.6
command: redis-server --appendonly yes
volumes:
# ./data/redis redis 数据文件存放地址,根据需要修改为本地地址
- './data/redis:/data'
networks:
- easy-mock
restart: always
web:
image: easymock/easymock:1.6.0
command: /bin/bash -c "npm start"
ports:
- 7300:7300
volumes:
# 日志地址,根据需要修改为本地地址
- './logs:/home/easy-mock/easy-mock/logs'
# 配置地址,请使用本地配置地址替换
# - './production.json:/home/easy-mock/easy-mock/config/production.json'
networks:
- easy-mock
restart: always
networks:
easy-mock:
production.json
{
"port": 7300,
"host": "0.0.0.0",
"pageSize": 30,
"proxy": false,
"db": "mongodb://mongodb/easy-mock",
"unsplashClientId": "",
"redis": {
"keyPrefix": "[Easy Mock]",
"port": 6379,
"host": "redis",
"password": "",
"db": 0
},
"blackList": {
"projects": [],
"ips": []
},
"rateLimit": {
"max": 1000,
"duration": 1000
},
"jwt": {
"expire": "14 days",
"secret": "shared-secret"
},
"upload": {
"types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
"size": 5242880,
"dir": "../public/upload",
"expire": {
"types": [".json", ".yml", ".yaml"],
"day": -1
}
},
"ldap": {
"server": "",
"bindDN": "",
"password": "",
"filter": {
"base": "",
"attributeName": ""
}
},
"fe": {
"copyright": "",
"storageNamespace": "easy-mock_",
"timeout": 25000,
"publicPath": "/dist/"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# 6.在当前目录下创建数据目录和日志目录并且给他们赋予权限
mkdir -p data/db
mkdir -p data/redis
mkdir logs
chmod -R 777 当前目录
1
2
3
4
2
3
4
# 7.安装镜像与创建容器
docker-compose up
# 8.访问
如果部署本地,则访问localhost:7300 如果部署服务器,则访问 服务器ip:7300
# 9.停止和启动
需要到当前目录下,与docker-compose.yml同级,进行启动停止
docker-compose stop
docker-compose start
1
2
2
验证: 新建docker-compose.yml
version: '3'
services:
mongodb:
image: mongo:3.4.1
volumes:
- ./data/db
- './data/db:/data/db'
networks:
- easy-mock
restart: always
redis:
image: redis:4.0.6
command: redis-server --appendonly yes
volumes:
- ./data/redis redis
- './data/redis:/data'
networks:
- easy-mock
restart: always
web:
image: easymock/easymock:1.6.0
command: /bin/bash -c "npm start"
ports:
- 7300:7300
volumes:
- './logs:/home/easy-mock/easy-mock/logs'
- './production.json:/home/easy-mock/easy-mock/config/production.json'
networks:
- easy-mock
restart: always
networks:
easy-mock:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
新建date logs production.json
mkdir -p data/db
mkdir -p data/redis
mkdir logs
chmod -R 777 当前目录
1
2
3
4
2
3
4
production.json
{
"port": 7300,
"host": "0.0.0.0",
"pageSize": 30,
"proxy": false,
"db": "mongodb://mongodb/easy-mock",
"unsplashClientId": "",
"redis": {
"keyPrefix": "[Easy Mock]",
"port": 6379,
"host": "redis",
"password": "",
"db": 0
},
"blackList": {
"projects": [],
"ips": []
},
"rateLimit": {
"max": 1000,
"duration": 1000
},
"jwt": {
"expire": "14 days",
"secret": "shared-secret"
},
"upload": {
"types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
"size": 5242880,
"dir": "../public/upload",
"expire": {
"types": [".json", ".yml", ".yaml"],
"day": -1
}
},
"ldap": {
"server": "",
"bindDN": "",
"password": "",
"filter": {
"base": "",
"attributeName": ""
}
},
"fe": {
"copyright": "",
"storageNamespace": "easy-mock_",
"timeout": 25000,
"publicPath": "/dist/"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52