From 42403dcd133cf3e0d4161221e7d9183b86e0d0b1 Mon Sep 17 00:00:00 2001 From: Rodolfo Neto Date: Thu, 22 Aug 2019 13:02:53 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Dar=20a=20op=C3=A7=C3=A3o=20ao=20usuario=20?= =?UTF-8?q?testar=20um=20script=20diretamente=20usando=20um=20container=20?= =?UTF-8?q?docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 19 +++++++++++++++++++ README.md | 16 ++++++++++++++++ exemplos/BotTerminal.sh | 7 +++++-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1191284 --- /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 no '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} \ No newline at end of file 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" From b1ced72d7a89708912d5f19236c3c464a5d03e95 Mon Sep 17 00:00:00 2001 From: Rodolfo Neto Date: Thu, 22 Aug 2019 10:05:40 -0300 Subject: [PATCH 2/2] Update Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pequena correção --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1191284..d53603b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apk add --update \ # necessário para ter o 'getopt' mais atual util-linux -# melhor maneira encontrada para pegar versão atual no 'jq' no alpine +# 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 @@ -16,4 +16,4 @@ RUN wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \ ARG token ENV TOKEN "${token}" -CMD /bin/bash /home/bot/exemplos/BotTerminal.sh ${TOKEN} \ No newline at end of file +CMD /bin/bash /home/bot/exemplos/BotTerminal.sh ${TOKEN}