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

3 Things I Hate About Kubernetes

Creating Collectable Objects In Unity And Updating The UI Once Collected

Coding on the go

A story about a not-so-direct SSRF

Grabathon Experience as Intern at Grab

Maxim Integrated’s EE-Sim OASIS ─ Quick and Efficient Power Supply Design

Why Technical Support for Virtual Meetings is a Game Changer

Laptop and a smiling technical support representative in the headphones

Powering Your E-Commerce Application with Image Classification

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

Solving issue of Docker Runtime ‘nvidia’ not found

From Zero to Hero with WebRTC in JavaScript and Python in small snippets of code. Part 1

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

Akulaku: Real-Time Feature Extraction for AI-Powered Risk Control