diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d53603b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine + +ADD . /home/bot + +RUN apk add --update \ + bash \ + curl \ + # necessário para ter o 'getopt' mais atual + util-linux + +# melhor maneira encontrada para pegar versão atual do 'jq' no alpine +RUN wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \ + chmod +x jq-linux64 && \ + mv jq-linux64 /usr/bin/jq + +ARG token +ENV TOKEN "${token}" + +CMD /bin/bash /home/bot/exemplos/BotTerminal.sh ${TOKEN} diff --git a/README.md b/README.md index c3d5a9c..8c5c282 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,22 @@ Exemplo: $ cp ShellBot.sh /projeto/meu_bot/ ``` +## Docker + +Para testar diretamente usando um container docker. Tenha em mãos o token do seu bot. + +``` +$ git clone https://github.com/shellscriptx/ShellBot.git && cd ShellBot +``` + +``` +$ docker build -t shellbot --build-arg "token=" . +``` + +``` +$ docker run -it shellbot +``` + ## Documentação Para mais informações consulte a documentação do projeto na página [wiki](https://github.com/shellscriptx/ShellBot/wiki). diff --git a/exemplos/BotTerminal.sh b/exemplos/BotTerminal.sh index 6d6fc57..88823ed 100755 --- a/exemplos/BotTerminal.sh +++ b/exemplos/BotTerminal.sh @@ -5,11 +5,14 @@ # Para melhor compreensão foram utilizados parâmetros longos nas funções; Podendo # ser substituidos pelos parâmetros curtos respectivos. +# Variável contem diretório onde o script reside +BASEDIR=$(dirname $0) + # Importando API -source ShellBot.sh +source ${BASEDIR}/../ShellBot.sh # Token do bot -bot_token='' +bot_token=$1 # Inicializando o bot com log. ShellBot.init --token "$bot_token" --monitor --flush --log_file "/tmp/${0##*/}.log"