Coding01

Coding 点滴

0%

rasax「docker compose」使用模式 (三)

Rasa X 介绍

Rasa X can be used in local mode and in server mode. Rasa X in local mode is helpful for sharing your assistant before you have a server set up. Once your assistant is up and running, you will want to deploy Rasa X to a server so that it’s available 24/7 and everyone on your team can use it to review conversations and annotate new training data.

之前介绍了本地模式,今天来折腾下 docker compose 模式。

要求服务器环境前提安装 python3, dockerdocker-compose

主要四个步骤:

  1. Download
  2. Install
  3. Start
  4. Access

Download

使用 Google Cloud Platform,大家可以搜索下使用方法,我这边主要结合阿里云使用的。

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
// 加速下载 rasa-x
docker pull rasa/rasa-x:0.31.0

docker tag docker.io/rasa/rasa-x:0.31.0 registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:0.31.0

docker push registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:0.31.0

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:0.31.0

docker pull rasa/duckling:0.1.6.3

docker tag docker.io/rasa/duckling:0.1.6.3 registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3

docker push registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3

docker pull rasa/rasa:1.10.8-full

docker tag docker.io/rasa/rasa:1.10.8-full registry.cn-hangzhou.aliyuncs.com/rasa/rasa:1.10.8-full

docker push registry.cn-hangzhou.aliyuncs.com/rasa/rasa:1.10.8-full

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/rasa:1.10.8-full

docker pull rasa/nginx:0.31.0

docker tag docker.io/rasa/nginx:0.31.0 registry.cn-hangzhou.aliyuncs.com/rasa/nginx:0.31.0

docker push registry.cn-hangzhou.aliyuncs.com/rasa/nginx:0.31.0

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/nginx:0.31.0

docker pull rasa/rasa-x-demo:0.31.0

docker tag docker.io/rasa/rasa-x-demo:0.31.0 registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:0.31.0

docker push registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:0.31.0

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:0.31.0

具体参考:https://cr.console.aliyun.com/

加速后,我重新修改了官网提供的配置文件:

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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
version: "3.4"

x-database-credentials: &database-credentials
DB_HOST: "db"
DB_PORT: "5432"
DB_USER: "${DB_USER:-admin}"
DB_PASSWORD: "${DB_PASSWORD}"
DB_LOGIN_DB: "${DB_LOGIN_DB:-rasa}"

x-rabbitmq-credentials: &rabbitmq-credentials
RABBITMQ_HOST: "rabbit"
RABBITMQ_USERNAME: "user"
RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}

x-redis-credentials: &redis-credentials
REDIS_HOST: "redis"
REDIS_PORT: "6379"
REDIS_PASSWORD: ${REDIS_PASSWORD}
REDIS_DB: "1"

x-duckling-credentials: &duckling-credentials
RASA_DUCKLING_HTTP_URL: "http://duckling:8000"

x-rasax-credentials: &rasax-credentials
RASA_X_HOST: "http://rasa-x:5002"
RASA_X_USERNAME: ${RASA_X_USERNAME:-admin}
RASA_X_PASSWORD: ${RASA_X_PASSWORD:-}
RASA_X_TOKEN: ${RASA_X_TOKEN}
JWT_SECRET: ${JWT_SECRET}
RASA_USER_APP: "http://app:5055"
RASA_PRODUCTION_HOST: "http://rasa-production:5005"
RASA_WORKER_HOST: "http://rasa-worker:5005"
RASA_TOKEN: ${RASA_TOKEN}

x-rasa-credentials: &rasa-credentials
<<: *rabbitmq-credentials
<<: *rasax-credentials
<<: *database-credentials
<<: *redis-credentials
<<: *duckling-credentials
RASA_TOKEN: ${RASA_TOKEN}
RASA_MODEL_PULL_INTERVAL: 10
RABBITMQ_QUEUE: "rasa_production_events"

x-rasa-services: &default-rasa-service
restart: always
image: "registry.cn-hangzhou.aliyuncs.com/rasa/rasa:${RASA_VERSION}-full"
expose:
- "5005"
command: >
x
--no-prompt
--production
--config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
--port 5005
--jwt-method HS256
--jwt-secret ${JWT_SECRET}
--auth-token '${RASA_TOKEN}'
--cors "*"
depends_on:
- rasa-x
- rabbit
- redis

services:
rasa-x:
restart: always
image: "registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:${RASA_X_VERSION}"
expose:
- "5002"
volumes:
- ./models:/app/models
- ./environments.yml:/app/environments.yml
- ./credentials.yml:/app/credentials.yml
- ./endpoints.yml:/app/endpoints.yml
- ./logs:/logs
- ./auth:/app/auth
environment:
<<: *database-credentials
<<: *rasa-credentials
SELF_PORT: "5002"
DB_DATABASE: "${DB_DATABASE:-rasa}"
RASA_MODEL_DIR: "/app/models"
PASSWORD_SALT: ${PASSWORD_SALT}
RABBITMQ_QUEUE: "rasa_production_events"
RASA_X_USER_ANALYTICS: "0"
SANIC_RESPONSE_TIMEOUT: "3600"
depends_on:
- db

rasa-production:
<<: *default-rasa-service
environment:
<<: *rasa-credentials
RASA_ENVIRONMENT: "production"
DB_DATABASE: "tracker"
RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

rasa-worker:
<<: *default-rasa-service
environment:
<<: *rasa-credentials
RASA_ENVIRONMENT: "worker"
DB_DATABASE: "worker_tracker"
RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

app:
restart: always
image: "registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:${RASA_X_DEMO_VERSION}"
expose:
- "5055"
depends_on:
- rasa-production

db:
restart: always
image: "daocloud.io/library/postgres:11.7"
expose:
- "5432"
environment:
POSTGRES_USER: "${DB_USER:-admin}"
POSTGRES_PASSWORD: "${DB_PASSWORD}"
POSTGRES_DB: "${DB_DATABASE:-rasa}"
volumes:
- ./db:/bitnami/postgresql

rabbit:
restart: always
image: "daocloud.io/library/rabbitmq:3.8.3"
environment:
RABBITMQ_HOST: "rabbit"
RABBITMQ_USERNAME: "user"
RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
RABBITMQ_DISK_FREE_LIMIT: "{mem_relative, 0.1}"
expose:
- "5672"

duckling:
restart: always
image: "registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3"
expose:
- "8000"
command: ["duckling-example-exe", "--no-access-log", "--no-error-log"]

nginx:
restart: always
image: "registry.cn-hangzhou.aliyuncs.com/rasa/nginx:${RASA_X_VERSION}"
ports:
- "80:8080"
- "443:8443"
volumes:
- ./certs:/opt/bitnami/certs
- ./terms:/opt/bitnami/nginx/conf/bitnami/terms
depends_on:
- rasa-x
- rasa-production
- app

redis:
restart: always
image: "daocloud.io/library/redis:5.0.8"
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD}
expose:
- "6379"

start

就可以创建容器了:

1
docker-compose up -d

access

执行命令:

1
python rasa_x_commands.py create --update admin me <PASSWORD>

好了,利用新密码就可以进入网页了。

总结

其中配置项主要参考官网说的来,这里就不再赘述了。

参考:https://rasa.com/docs/rasa-x/installation-and-setup/install/docker-compose

Welcome to my other publishing channels