Skip to content

Dockerizando o bot #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<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).
7 changes: 5 additions & 2 deletions exemplos/BotTerminal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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='<TOKEN_AQUI>'
bot_token=$1

# Inicializando o bot com log.
ShellBot.init --token "$bot_token" --monitor --flush --log_file "/tmp/${0##*/}.log"
Expand Down