Skip to content

Commit

Permalink
more work on docker
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 19, 2018
1 parent dfa7dcf commit 056dc23
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
20 changes: 11 additions & 9 deletions chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@ python -m grpc_tools.protoc -I../pbx --python_out=. --grpc_python_out=. ../pbx/m

### Using Docker

1. Follow [instructions](../docker/README.md) to build and run dockerized Tinode chat server up to an including _step 5_.
**Warning!** The chatbot image is almost 750MB: the basic Python 3 docker image is nearly 690MB, gRPC adds another 60MB.

1. Follow [instructions](../docker/README.md) to build and run dockerized Tinode chat server up to an including _step 3_.

2. In _step 6_ run the server adding `--env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true` and `--volume botdata:/botdata` to the command line:
2. In _step 4_ run the server adding `--env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true` and `--volume botdata:/botdata` to the command line:
1. **RethinkDB**:
```
$ docker run -p 6060:18080 -d --name tinode-srv --env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true --volume botdata:/botdata --network tinode-net tinode-srv
$ docker run -p 6060:18080 -d --name tinode-srv --env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true --volume botdata:/botdata --network tinode-net tinode/tinode-rethink:latest
```

3. If the current folder is `chat/chatbot`, then the Dockerfile is located in `chat/docker/chatbot` folder; `cd ../docker` and build the chat bot image
1. **MySQL**:
```
$ docker build --tag=tinode-bot chatbot
$ docker run -p 6060:18080 -d --name tinode-srv --env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true --volume botdata:/botdata --network tinode-net tinode/tinode-mysql:latest
```

4. Run the chatbot
3. Run the chatbot
```
$ docker run -d --name tinode-bot --network tinode-net --volume botdata:/botdata tinode-bot
$ docker run -d --name tino-chatbot --network tinode-net --volume botdata:/botdata tinode/chatbot:latest
```

5. Test that the bot is functional by pointing your browser to [http://localhost:6060/x/](http://localhost:6060/x/), login and talk to user `Tino`. The user should respond to every message with a random quote.
4. Test that the bot is functional by pointing your browser to http://localhost:6060/x/, login and talk to user `Tino`. The user should respond to every message with a random quote.


### Building from Source
Expand Down
2 changes: 2 additions & 0 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ fi
ver=( ${tag//./ } )

# Remove earlier builds
docker rmi tinode-rethinkdb
docker rmi tinode/tinode-rethinkdb:latest
docker rmi tinode/tinode-rethinkdb:"${ver[0]}.${ver[1]}.${ver[2]}"
docker rmi tinode/tinode-rethinkdb:"${ver[0]}.${ver[1]}"
docker rmi tinode-mysql
docker rmi tinode/tinode-mysql:latest
docker rmi tinode/tinode-mysql:"${ver[0]}.${ver[1]}.${ver[2]}"
docker rmi tinode/tinode-mysql:"${ver[0]}.${ver[1]}"
Expand Down
22 changes: 14 additions & 8 deletions docker/chatbot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
# Dockerfile builds an image with a chatbot (Tino) for Tinode.

FROM python:3

ARG VERSION=0.14.4
ENV VERSION=$VERSION

LABEL maintainer="Gene Sokolov <gene@tinode.co>"
LABEL name="TinodeChatbot"
LABEL version="0.14.1"
LABEL version=$VERSION

RUN mkdir -p /usr/src/bot
WORKDIR /usr/src/bot

COPY requirements.txt ./
COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -q -r requirements.txt

ADD https://raw.githubusercontent.com/tinode/chat/master/chatbot/chatbot.py /usr/src/bot
ADD https://raw.githubusercontent.com/tinode/chat/master/chatbot/quotes.txt /usr/src/bot
ADD https://raw.githubusercontent.com/tinode/chat/master/pbx/model_pb2.py /usr/src/bot
ADD https://raw.githubusercontent.com/tinode/chat/master/pbx/model_pb2_grpc.py /usr/src/bot
# Get tarball with the chatbot code and data.
ADD https://github.com/tinode/chat/releases/download/v$VERSION/chatbot.tar.gz .
# Unpack chatbot, delete archive
RUN tar -xzf chatbot.tar.gz \
&& rm chatbot.tar.gz

# Use command line parameter `-e LOGIN_AS=user:password` to login as someone other than Tino.

ENTRYPOINT python chatbot.py --login-basic=${LOGIN_AS} --login-cookie=/botdata/.tn-cookie --host=tinode-srv:16061 > log.txt
ENTRYPOINT python chatbot.py --login-basic=${LOGIN_AS} --login-cookie=/botdata/.tn-cookie --host=tinode-srv:16061 > /var/log/chatbot.log

# Plugin port
EXPOSE 40051
3 changes: 2 additions & 1 deletion docker/tinode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ WORKDIR /opt/tinode

ADD https://github.com/tinode/chat/releases/download/v$VERSION/tinode-$TARGET_DB.linux-amd64.tar.gz .

RUN tar -xzf tinode-$TARGET_DB.linux-amd64.tar.gz
RUN tar -xzf tinode-$TARGET_DB.linux-amd64.tar.gz \
&& rm tinode-$TARGET_DB.linux-amd64.tar.gz

# Copy config template to the container.
COPY config.template .
Expand Down

0 comments on commit 056dc23

Please sign in to comment.