Building the docker-compose.yaml to run or init Rasa bot

docker-compose.yaml

version: '3.8'
services:
rasa:
image: rasa/rasa:3.0.0-full
container_name: rasa
ports:
- 5005:5005
user: "$UID:$GID"
volumes:
#- ./rasa_data:/app
- "${BIND_FOLDER}:/app"
command:
# - "run" # original hard code value as array entry
# - "--enable-api"
# - "${COMMAND}" # tried to mimic the array approach
# - "${COMMAND_ARG}" # but init command not allow this switch, even it's empty string
"${COMMAND}" # this is string, allow command as string like 'run --enable-api' or 'init'

Volume mapping

User mapping

Command

Script to execute the docker-compose

#!/bin/bash# Check if folder path exist
if [ -z "$1" ]; then
echo "ERROR: Missing argument volume"
echo "Usage: $0 <rasa folder> <command> <command arg>"
echo "example 1: $0 ./rasa_data run --enable-api"
echo "example 2: $0 ./rasa_data init"
exit 1
fi
echo "Volume expected to be $1"# Arg after folder
ARGS="${@:2}"
echo "Arguments are $ARGS"
if [ -d "$1" ]; then
if [ "$2" = "run" ]; then
echo "Run 'docker-compose up -d' ..."
eval "env UID=$(id -u) GID=$(id -g) BIND_FOLDER=$1 COMMAND=$ARGS docker-compose up -d"
echo "Running 'docker-compose logs -f' ..."
eval "docker-compose logs -f"
fi
if [ "$2" = "init" ]; then
echo "Run 'docker-compose run' ..."
eval "env UID=$(id -u) GID=$(id -g) BIND_FOLDER=$1 docker-compose run rasa $ARGS"
#echo "Running 'docker-compose logs -f' ..."
#eval "docker-compose logs -f"
fi
else
echo "ERROR: the folder '$1' does not exist"
exit 1
fi
running the script with “bash rasa_script.sh ./product_selling_bot init”

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Lives and Respawn System in Unity

Serverless Revolution: the Good, the Bad and the Ugly

[LeetCode]#182. Duplicate Emails

Huawei Search Kit

Using Bollinger Bands to Trade Cryptocurrency with Python

How to setup Deep Learning environment on AWS GPU instance

Code Smell 118 — Return False

IRISnet Mainnet 1.1 Successfully Upgraded Within Around 40 Minutes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stephen Cow Chau

Stephen Cow Chau

More from Medium

Information Extraction from scanned images using Tesseract OCR

Word Embedding Using FastText

Fake News Detection Project

Perform Profanity and Obscene Language Analysis and Detection on Text in Python