Skip to content

Commit

Permalink
feat(documentation): docker & docker-compose sample (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ealenn authored Apr 5, 2021
1 parent 53089a1 commit 7617796
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 66 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
88 changes: 24 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,89 +10,49 @@ 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
- x.x.x: Release version x.x.x
- 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:
Expand Down
3 changes: 3 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
set -e
exec node /app/Application.js
4 changes: 4 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
116 changes: 116 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -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
```
39 changes: 39 additions & 0 deletions docs/deployment/docker-compose.md
Original file line number Diff line number Diff line change
@@ -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 !'
```
38 changes: 38 additions & 0 deletions docs/deployment/docker.md
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 4 additions & 0 deletions docs/deployment/index.md
Original file line number Diff line number Diff line change
@@ -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...)

0 comments on commit 7617796

Please sign in to comment.