From 1c3cb036411f9bd967d754d9342b3ff03261a28c Mon Sep 17 00:00:00 2001 From: ArthurTemporim Date: Mon, 21 Oct 2019 02:06:05 -0300 Subject: [PATCH] Improve coach configuration Signed-off-by: ArthurTemporim --- Makefile | 8 ++++---- bot/Makefile | 2 +- docker-compose.yml | 9 +++++++-- docker/actions.Dockerfile | 2 +- docker/bot.Dockerfile | 6 +----- docker/coach.Dockerfile | 10 +++------- docker/requirements.Dockerfile | 2 +- 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 86b44b94..4713c3d8 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,13 @@ build: make build-bot build-requirements: - docker build . -f docker/requirements.Dockerfile -t lappis/botrequirements:boilerplate + docker build . -f docker/requirements.Dockerfile -t botrequirements build-bot: docker-compose build bot build-coach: - docker-compose build coach + docker-compose up coach build-analytics: docker-compose up -d elasticsearch @@ -30,7 +30,7 @@ build-analytics: docker-compose run --rm -v $(current_dir)/modules/analytics/setup_elastic.py:/analytics/setup_elastic.py bot python /analytics/setup_elastic.py docker-compose run --rm -v $(current_dir)/modules/analytics/:/analytics/ bot python /analytics/import_dashboards.py echo "Não se esqueça de atualizar o arquivo endpoints.yml" - #sensible-browser --no-sandbox http://localhost:5601 + sensible-browser --no-sandbox http://localhost:5601 run-analytics: docker-compose up -d rabbitmq @@ -54,7 +54,7 @@ run-notebooks: sensible-browser --no-sandbox http://localhost:8888 train: - docker build . -f docker/coach.Dockerfile -t lappis/coach:boilerplate + docker-compose up coach docker-compose build bot validate: diff --git a/bot/Makefile b/bot/Makefile index b549212d..33aaa637 100644 --- a/bot/Makefile +++ b/bot/Makefile @@ -1,6 +1,6 @@ ############################## BOT ############################## train: - rasa train -vv + rasa train -vv --out models/ shell: rasa shell -m models/ -vv --endpoints endpoints.yml --port 5004 --cors "*" diff --git a/docker-compose.yml b/docker-compose.yml index 92456b2b..d92951f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,13 @@ services: # =============================== Coach ================================= # All the models are trained by this coach. coach: - image: lappis/coach:boilerplate - command: sh -c "cp -r /src_models/* " + build: + context: . + dockerfile: ./docker/coach.Dockerfile + volumes: + - ./bot/models/:/bot/models/ + command: sh -c "make train" + # ================================= Bot ===================================== # Generic Rasa bot, used to run console for example. diff --git a/docker/actions.Dockerfile b/docker/actions.Dockerfile index e8236dc0..40b61866 100644 --- a/docker/actions.Dockerfile +++ b/docker/actions.Dockerfile @@ -1,4 +1,4 @@ -FROM lappis/botrequirements:boilerplate +FROM botrequirements COPY ./bot/actions/actions.py /bot/actions/actions.py COPY ./bot/Makefile /bot/Makefile diff --git a/docker/bot.Dockerfile b/docker/bot.Dockerfile index 3b001519..4e62771c 100644 --- a/docker/bot.Dockerfile +++ b/docker/bot.Dockerfile @@ -1,12 +1,8 @@ -FROM lappis/coach:boilerplate as coach -FROM lappis/botrequirements:boilerplate +FROM botrequirements WORKDIR /bot COPY ./bot /bot COPY ./modules /modules -COPY --from=coach /src_models/ /bot/models/ - -RUN chown -R 1001 /bot/models && chmod -R 750 /bot/models RUN find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf diff --git a/docker/coach.Dockerfile b/docker/coach.Dockerfile index 514350e7..5d1ec182 100644 --- a/docker/coach.Dockerfile +++ b/docker/coach.Dockerfile @@ -1,11 +1,7 @@ -FROM lappis/botrequirements:boilerplate +FROM botrequirements as coach -COPY ./bot/ /coach/ +WORKDIR /bot -RUN mkdir /src_models - -WORKDIR /coach +COPY ./bot/ /bot/ RUN make train - -RUN find /. | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf diff --git a/docker/requirements.Dockerfile b/docker/requirements.Dockerfile index f2dc756d..4291b436 100644 --- a/docker/requirements.Dockerfile +++ b/docker/requirements.Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6-slim +FROM python:3.6-slim as botrequirements RUN apt update && apt install -y gcc make