feat: Dockerize

This commit is contained in:
MrTuxedo 2023-05-04 14:35:58 -07:00
parent d5fcc4060c
commit c5116079ac
4 changed files with 40 additions and 2 deletions

10
Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM python:bullseye
WORKDIR /usr/src/app
COPY server2serverMessageBot.py ./
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir discord.py
CMD python3 server2serverMessageBot.py

19
README.md Normal file
View File

@ -0,0 +1,19 @@
# Server2ServerMessageBot
> Forked from https://github.com/birthdaysmoothie22/Server2ServerMessageBot/
## Environment
Please add env vars as in this example:
```sh
BOT_KEY=<discord_bot_key>
CHANNEL_ID_PAIRS={"sender_channel_id_1" : receiver_channel_id_1, "sender_channel_id_2" : receiver_channel_id_2}
```
## Docker Compose
It is assumed you are using a recent version of docker compose to build and run this bot:
```sh
docker compose up -d
```

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3'
services:
server2server-bot:
build: .
container_name: server2server-bot
environment:
- BOT_KEY
- CHANNEL_ID_PAIRS
restart: unless-stopped

View File

@ -1,10 +1,10 @@
import discord import discord
import json import json
import os import os
from dotenv import load_dotenv #from dotenv import load_dotenv
#load environment variables #load environment variables
load_dotenv() #load_dotenv()
BOT_KEY = os.getenv('BOT_KEY') BOT_KEY = os.getenv('BOT_KEY')
CHANNEL_ID_PAIRS = json.loads(os.getenv('CHANNEL_ID_PAIRS')) CHANNEL_ID_PAIRS = json.loads(os.getenv('CHANNEL_ID_PAIRS'))