added docker configs

This commit is contained in:
Hendrik Behme committed 2019-08-26 17:56:46 +02:00
1 parent a89f0df161
commit 5cb6bccd7f
28 files changed
+97 -13

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
COMPOSE_FILE=docker-compose.yml
COMPOSE_DIR=.
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=SetYourOwnPassword
MONGO_INITDB_DATABASE=pollmaster
# official discord bot token
DISCORD_BOT_TOKEN=
# owner user id
OWNER_ID=
# Sets the invite client id
INVITE_CLIENT_ID=
+18
View File
@@ -0,0 +1,18 @@
FROM alpine:3.10.2
WORKDIR '/tmp'
COPY ./pm /data/pm
RUN apk update && apk add bash nodejs npm python3 python3-dev freetype-dev subversion
RUN apk --no-cache --update-cache add gcc gfortran build-base wget libpng-dev openblas-dev
RUN pip3 install --upgrade pip
WORKDIR '/data/pm'
RUN pip install pykg-config
RUN pip install -r requirements.txt
CMD python3 pollmaster.py
+42
View File
@@ -0,0 +1,42 @@
# Use root/example as user/password credentials
version: '3.1'
services:
# Database
mongo:
image: mongo:latest
restart: always
volumes:
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
- MONGO_INITDB_ROOT_USERNAME
- MONGO_INITDB_ROOT_PASSWORD
- MONGO_INITDB_DATABASE
# App - Container, where the main application runs
app:
restart: always
volumes:
- ./pm/cogs/poll_controls.py:/data/pm/cogs/poll_controls.py
- ./pm/pollmaster.py:/data/pm/pollmaster.py
links:
- mongo
build:
context: .
dockerfile: Dockerfile
environment:
- DISCORD_BOT_TOKEN
- MONGO_INITDB_ROOT_USERNAME
- MONGO_INITDB_ROOT_PASSWORD
- OWNER_ID
- INVITE_CLIENT_ID
# Admin Interface for Database
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: $MONGO_INITDB_ROOT_USERNAME
ME_CONFIG_MONGODB_ADMINPASSWORD: $MONGO_INITDB_ROOT_PASSWORD
+1 -1
View File
@@ -1,5 +1,5 @@
# IDE Folders
\.idea/
../.idea/
# PY VENV
venv/
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
@@ -1,4 +1,5 @@
import argparse
import os
import asyncio
import datetime
import logging
@@ -8,6 +9,8 @@ import shlex
import discord
import pytz
import time
from discord.ext import commands
from utils.misc import CustomFormatter
@@ -47,7 +50,9 @@ class PollControls(commands.Cog):
while True:
try:
if not hasattr(self.bot, 'db'):
await asyncio.sleep(30)
"""await asyncio.sleep(30)"""
logger.info("DB not available yet")
time.sleep(30)
continue
query = self.bot.db.polls.find({'active': False, 'activation': {"$not": re.compile("0")}})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,5 @@
import discord
import os
from essentials.secrets import SECRETS
@@ -9,11 +10,11 @@ class Settings:
self.title_icon = "https://i.imgur.com/vtLsAl8.jpg" #PM
self.author_icon = "https://i.imgur.com/TYbBtwB.jpg" #tag
self.report_icon = "https://i.imgur.com/YksGRLN.png" #report
self.owner_id = 117687652278468610
self.msg_errors = False
self.owner_id = os.environ.get('OWNER_ID')
self.msg_errors = True
self.log_errors = True
self.invite_link = \
'https://discordapp.com/api/oauth2/authorize?client_id=444831720659877889&permissions=126016&scope=bot'
'https://discordapp.com/api/oauth2/authorize?client_id=%s&permissions=126016&scope=bot' % (os.environ.get('INVITE_CLIENT_ID'))
self.load_secrets()
File renamed without changes.
Binary file not shown.
Binary file not shown.
File renamed without changes.
+12 -8
View File
@@ -43,17 +43,9 @@ ch.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(ch)
extensions = ['cogs.config', 'cogs.poll_controls', 'cogs.help', 'cogs.db_api', 'cogs.admin']
for ext in extensions:
bot.load_extension(ext)
@bot.event
async def on_ready():
bot.owner = await bot.fetch_user(SETTINGS.owner_id)
mongo = AsyncIOMotorClient(SETTINGS.mongo_db)
bot.db = mongo.pollmaster
bot.session = aiohttp.ClientSession()
print(bot.db)
@@ -71,6 +63,7 @@ async def on_ready():
except:
print("Problem verifying servers.")
logger.error("Problem verifying servers.")
# cache prefixes
bot.pre = {entry['_id']: entry['prefix'] async for entry in bot.db.config.find({}, {'_id', 'prefix'})}
@@ -82,6 +75,7 @@ async def on_ready():
await bot.change_presence(status=discord.Status.online, activity=game)
print("Servers verified. Bot running.")
logger.info("Servers verified. Bot running.")
@bot.event
async def on_command_error(ctx, e):
@@ -136,4 +130,14 @@ async def on_guild_join(server):
)
bot.pre[str(server.id)] = 'pm!'
logger.info("Connecting to Mongo DB: " + SETTINGS.mongo_db)
mongo = AsyncIOMotorClient(SETTINGS.mongo_db)
bot.db = mongo.pollmaster
print(bot.db)
extensions = ['cogs.config', 'cogs.poll_controls', 'cogs.help', 'cogs.db_api', 'cogs.admin']
for ext in extensions:
logger.info("Loading extension " + ext)
bot.load_extension(ext)
bot.run(SETTINGS.bot_token)
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.