From 76177964de5588012b4629e47d1cd5eed7fa2296 Mon Sep 17 00:00:00 2001 From: Marchandise Rudy Date: Mon, 5 Apr 2021 16:57:39 +0200 Subject: [PATCH] feat(documentation): docker & docker-compose sample (#18) --- Dockerfile | 8 ++- README.md | 88 +++++++---------------- docker/entrypoint.sh | 3 + docs/_config.yml | 4 ++ docs/configuration.md | 116 ++++++++++++++++++++++++++++++ docs/deployment/docker-compose.md | 39 ++++++++++ docs/deployment/docker.md | 38 ++++++++++ docs/deployment/index.md | 4 ++ 8 files changed, 234 insertions(+), 66 deletions(-) create mode 100644 docker/entrypoint.sh create mode 100644 docs/configuration.md create mode 100644 docs/deployment/docker-compose.md create mode 100644 docs/deployment/docker.md create mode 100644 docs/deployment/index.md diff --git a/Dockerfile b/Dockerfile index 115ff94..b82b682 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,9 @@ FROM node:14-alpine as final WORKDIR /app COPY --from=build /build/dist . COPY --from=build /build/node_modules ./node_modules -ENTRYPOINT [ "node" ] -CMD [ "Application.js" ] +COPY ./docker/entrypoint.sh /app/entrypoint.sh +RUN chmod +x /app/entrypoint.sh + +WORKDIR /bot +ENV LARBIN_FILE=/bot +ENTRYPOINT [ "/app/entrypoint.sh" ] diff --git a/README.md b/README.md index 4eb3dca..a56842a 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,22 @@ Completely customizable Twitch Bot. ![](./docs/assets/images/larbinbot.png) +```bash +docker run --rm \ + -e DEBUG=true \ + -e LARBIN_TWITCH_USERNAME= Larbin \ + -e LARBIN_TWITCH_PASSWORD= oic:password \ + -e LARBIN_TWITCH_CHANNEL= example \ + -e LARBIN_FILE= /bot \ + -v $PWD/config:/bot \ + ealenn/larbinbot +``` + +More information about deployment here [https://ealenn.github.io/LarbinBot/deployment](https://ealenn.github.io/LarbinBot/deployment) + ## Version -The versioning scheme we use is [SemVer](http://semver.org/). +The versioning scheme is [SemVer](http://semver.org/). ``` yml - latest: Master Build @@ -20,79 +33,26 @@ The versioning scheme we use is [SemVer](http://semver.org/). - snapshot: Pull Request / Internal Tests ``` -## Getting Started - -### Structure - -```bash -/my-bot-folder -│ docker-compose.yml -└───config -| └─── larbin.yml -``` - -Docker-Compose : -```yaml -# .../my-bot-folder/docker-compose.yml -version: "3" - -services: - bot: - image: ealen/larbinbot:latest - environment: - - DEBUG: true - - LARBIN_FILE: /tmp - - LARBIN_TWITCH_USERNAME: Larbin - - LARBIN_TWITCH_PASSWORD: oic:password - - LARBIN_TWITCH_CHANNEL: example - volumes: - - ${PWD}/config:/tmp -``` - -> You can use [https://twitchapps.com/tmi/](https://twitchapps.com/tmi/) to generate bot password. - -Larbin Configuration File : -```yml -# .../my-bot-folder/config/larbin.yml -commands: - - name: '!hello' - policies: - others: true - messages: - - 'Hello from my bot !' -``` - -```bash -docker-compose up -d -``` - -## Larbin Configuration File (LCF) - -You must configure this bot with configuration file `larbin.yml`. -This file contain all actions/events and commands. -By default, this file is on the root of project. - -You can override path of this file with envirenment variable : +## Environment Variables ``` bash +# Path to larbin.yml configuration file LARBIN_FILE=/tmp -``` - -You can also use DEBUG MODE with : - -``` bash +# Debug mode DEBUG=true -``` -## Larbin Credentials - -``` bash +# Twitch Credentials LARBIN_TWITCH_USERNAME: Larbin LARBIN_TWITCH_PASSWORD: oic:password LARBIN_TWITCH_CHANNEL: example ``` -### Sample +## Larbin Configuration File (LCF) + +You must configure this bot with configuration file `larbin.yml`. +This file contain all actions/events and commands. + +More information about Larbin Configuration File here [https://ealenn.github.io/LarbinBot/configuration](https://ealenn.github.io/LarbinBot/configuration) ``` yaml tools: diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..5f3114c --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +exec node /app/Application.js diff --git a/docs/_config.yml b/docs/_config.yml index b41933f..7a752c4 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -7,6 +7,10 @@ plugins: - jekyll-toc navbar-links: + Deployment: + - Docker: "deployment/docker" + - Docker-Compose: "deployment/docker-compose" + Configuration: "configuration" Release Notes: "release-notes" # Welcome to Beautiful Jekyll! diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 0000000..703b376 --- /dev/null +++ b/docs/configuration.md @@ -0,0 +1,116 @@ +# Configuration + +## Environment Variables + +``` bash +# Path to larbin.yml configuration file +LARBIN_FILE=/tmp + +# Debug mode +DEBUG=true + +# Twitch Credentials +LARBIN_TWITCH_USERNAME: Larbin +LARBIN_TWITCH_PASSWORD: oic:password +LARBIN_TWITCH_CHANNEL: example +``` + +## Larbin Configuration File + +You must configure this bot with configuration file `larbin.yml`. +This file contain all actions/events and commands. + +### Commands + +```yaml +commands: + - name: '!facebook' # Command to write + random: false # Takes a random message from the list rather than following the order of the list + policies: + others: true # All + messages: + - 'My Facebook is https://facebook.com/example' + - name: '!twitter' + policies: + others: true # All + messages: + - 'My Twitter is https://twitter.com/example' +``` + +### Schedulers + +```yaml +schedulers: + - id: 'social' # Required, is only used to make this scheduler unique + minutes: 10 # Send message every minutes + random: true # Takes a random message from the list rather than following the order of the list + messages: + - 'Follow me on Twitter https://twitter.com/example' + - id: 'other' + minutes: 5 + messages: + - 'Text rolling 1' + - 'Text rolling 2' + - 'Text rolling 3' +``` + +### Events + +```yaml +events: + - name: 'join' # Event type + random: true # Takes a random message from the list rather than following the order of the list + messages: + - 'Less noise {{ Username }} is coming!' + - 'Ah! We are talking about you {{ Username }} !' + - name: 'raided' + messages: + - 'Thanks to {{ Username }} for this raid of {{ Viewers }} viewers !' + - name: 'resub' + messages: + - 'Thanks {{ Username }} for your {{ Months }} with us ! -- {{ Username }} say: {{ Message }}' + - name: 'submysterygift' + messages: + - '{{ Username }} is rich and he just offered {{ OfferedSubs }} subscription! Thank him in the chat! (with a total of {{ GiftCount }} subscription offered)' + - name: 'subgift' + messages: + - 'Hey ! {{ Username }} is {{ GiftCount }}x more generous with {{ RecipientUsername }} !' + - name: 'subscription' + messages: + - 'I know someone from sub, but, I say anything, alright {{ Username }} ?' +``` + +### Tools + +```yaml +tools: + commands: + # Command to start/stop schedulers + # (The schedulers is started by default on bot starting.) + # Example: + # !schedulers status + # !schedulers on + # !schedulers off + - type: schedulers + name: '!schedulers' + policies: + mod: true + admin: true + argOn: 'on' + argOff: 'off' + argStatus: 'status' +``` + +### Policies + +**Warning**, by default, everything is blocked for everyone. You must allow at least one. + +``` yaml +# DEFAULT POLICIES VALUES +policies: + admin: false # Allow Admins/Streamer + mod: false # Allow Moderators + vip: false # Allow VIP + sub: false # Allow Subscriber + others: false # Allow/Disallow all/others +``` diff --git a/docs/deployment/docker-compose.md b/docs/deployment/docker-compose.md new file mode 100644 index 0000000..7a99baf --- /dev/null +++ b/docs/deployment/docker-compose.md @@ -0,0 +1,39 @@ +# Docker-Compose + +## Project + +```bash +/mybot +│ docker-compose.yml +└───config +| └─── larbin.yml +``` + +### Docker-Compose + +```yml +version: "3" + +services: + bot: + image: ealen/larbinbot:latest + environment: + - DEBUG: true + - LARBIN_FILE: /tmp + - LARBIN_TWITCH_USERNAME: Larbin + - LARBIN_TWITCH_PASSWORD: oic:password + - LARBIN_TWITCH_CHANNEL: example + volumes: + - ${PWD}/config:/tmp +``` + +### Larbin Configuration + +``` yaml +commands: + - name: '!hello' + policies: + others: true + messages: + - 'Hello from my bot !' +``` diff --git a/docs/deployment/docker.md b/docs/deployment/docker.md new file mode 100644 index 0000000..7aa8ec1 --- /dev/null +++ b/docs/deployment/docker.md @@ -0,0 +1,38 @@ +# Docker + +## Project + +```bash +/mybot +│ Dockerfile +| larbin.yml +``` + +### Dockerfile + +```docker +FROM ealen/larbinbot:latest +COPY larbin.yml . +``` + +### Larbin Configuration + +``` yaml +commands: + - name: '!hello' + policies: + others: true + messages: + - 'Hello from my bot !' +``` + +## Run + +```bash +docker run --rm \ + -e DEBUG=true \ + -e LARBIN_TWITCH_USERNAME= Larbin \ + -e LARBIN_TWITCH_PASSWORD= oic:password \ + -e LARBIN_TWITCH_CHANNEL= example \ + my-custom-image:latest +``` diff --git a/docs/deployment/index.md b/docs/deployment/index.md new file mode 100644 index 0000000..e15c830 --- /dev/null +++ b/docs/deployment/index.md @@ -0,0 +1,4 @@ +# Deployment + +- [Docker](./docker) : Run LarbinBot with your custom Docker Image (ex: to deploy on Heroky, Azure, AWS etc...) +- [Docker-Compose](./docker-compose) : Run LarbinBot on Docker-Compose (ex: Local development, raspberry, VPS etc...)