Skip to content

Commit

Permalink
add docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
colin.gao committed Sep 18, 2019
1 parent e9e8a77 commit 036a8b6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
**edit at 2019.06.24**
将之前的[rasa-nlu-gao](https://github.com/GaoQ1/rasa_nlu_gq)进行了修改,以支持新版本的rasa,而且不再在源码里进行修改。首先需要`pip install rasa-nlu-gao>=0.3.1`,具体用法如下。

## Command
## Running by command
### install packages
- python >= 3.5
- python >= 3.6
```
pip install -r requirements.txt
```
Expand All @@ -29,7 +29,7 @@ pip install -r requirements.txt
```
make train
```
训练nlu和core模型,新版本中会将模型自动打包成zip文件
训练nlu和core模型,新版本中会将模型自动打包成zip文件

### run model
```
Expand Down Expand Up @@ -88,5 +88,10 @@ make run-x

## some problems
Q: 为什么我会报`couldn't find component...`这个错?

A: rasa使用了importlib动态加载自定义component和policy。这个错误的原因是你没有将component和policy的目录append到PYTHONPATH里面。你需要`export PYTHONPATH=/path/to/your/component`

Q: 为什么训练会报10000time超时错误?
A: 这个问题是因为你没有启用bert-as-service服务。启动教程参考[rasa对话系统踩坑记(八)](https://www.jianshu.com/p/6a93209c48a4),启动之后在config.yml将对用的bert-as-service服务ip改下,本例子默认是127.0.0.1,但是你要在本机启动bert服务

Q: 如何能够快速尝试例子呢?
A: 介于各个开发环境不同,报各种错误,所以上传了docker文件。但前提还是你要安装docker,并在运行前确保bert-as-service启用,当然你不用bert的话可以忽略。然后你只需要`sh dev/deploy_dev.sh`,就可以愉快的通过postman或者curl测试这个demo了。记得`docker logs -f chatbot_dev`查看有没有训练完,有没有报错。linux和mac下没有问题。windows下可能需要微调下。
5 changes: 5 additions & 0 deletions configs/endpoints.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
action_endpoint:
url: http://localhost:5055/webhook

tracker_store:
store_type: mongod
url: mongodb://mongo:27017
db: chatbot
42 changes: 42 additions & 0 deletions dev/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM python:3.6-slim

SHELL ["/bin/bash", "-c"]

# Default to UTF-8 file.encoding
ENV LANG C.UTF-8

RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
apt-utils \
vim \
procps \
build-essential \
wget \
unzip \
openssh-client \
graphviz-dev \
pkg-config \
git-core \
openssl \
libssl-dev \
libffi6 \
libffi-dev \
libpng-dev \
curl \
python3-tk \
tk-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
mkdir /app

WORKDIR /app

ENV PYTHONPATH "${PYTHONPATH}:/app"

COPY requirements.txt ./

RUN pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ && \
pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

ENTRYPOINT ["/bin/sh"]
CMD ["/app/dev/run.sh"]
12 changes: 12 additions & 0 deletions dev/deploy_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
if [ ! "$(docker ps -a | grep mongo)" ]
then echo "start mongo db docker";
mkdir ~/data;
docker pull mongo;
docker run --name mongo -p 27017:27017 -v ~/data:/data/db -itd mongo;
fi

CHATBOT_VERSION=0.0.1

docker build -f dev/Dockerfile.dev . -t chatbot_dev:$CHATBOT_VERSION
docker run --name chatbot_dev -p 5005:5005 -p 5002:5002 --link mongo -v "$PWD":/app -itd chatbot_dev:$CHATBOT_VERSION
4 changes: 4 additions & 0 deletions dev/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

make train
make run
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
keras
keras==2.2.4
rasa-nlu-gao>=0.3.0
rasa-sdk
rasa-sdk~=1.1.0

0 comments on commit 036a8b6

Please sign in to comment.