containerize this thing
This commit is contained in:
parent
b77e105d5c
commit
0fc4482bdf
5 changed files with 61 additions and 9 deletions
11
.dockerignore
Normal file
11
.dockerignore
Normal file
|
@ -0,0 +1,11 @@
|
|||
__pycache__/
|
||||
*.py[cod]
|
||||
*.yaml
|
||||
*.db
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.vscode/
|
||||
.git/
|
||||
.gitignore
|
||||
Dockerfile
|
||||
.dockerignore
|
14
Dockerfile
Normal file
14
Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
|||
FROM python:alpine3.7
|
||||
|
||||
VOLUME /data
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
CMD [ "python", "/usr/src/app/partybot-pnut.py", "-d", "-c", "config.yaml" ]
|
|
@ -1,5 +1,7 @@
|
|||
from sqlalchemy import Column, ForeignKey, Integer, String, Boolean
|
||||
from database import Base
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
class Optout(Base):
|
||||
__tablename__ = 'optout'
|
||||
|
|
|
@ -8,10 +8,13 @@ import time
|
|||
import json
|
||||
import random
|
||||
import re
|
||||
import argparse
|
||||
|
||||
from database import db_session, init_db
|
||||
from sqlalchemy import and_
|
||||
from models import Karma, Optout, Queue, Preferences, MdnpRequests
|
||||
# from database import db_session, init_db
|
||||
from sqlalchemy import create_engine, and_
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from models import Base, Karma, Optout, Queue, Preferences, MdnpRequests
|
||||
|
||||
_startup = threading.Event()
|
||||
_shutdown = threading.Event()
|
||||
|
@ -348,12 +351,29 @@ def on_open(ws):
|
|||
if __name__ == "__main__":
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
a_parser = argparse.ArgumentParser()
|
||||
a_parser.add_argument(
|
||||
'-d', action='store_true', dest='debug',
|
||||
help="debug logging"
|
||||
)
|
||||
a_parser.add_argument(
|
||||
'-c', '--config', default="config.yaml",
|
||||
help="configuration file"
|
||||
)
|
||||
args = a_parser.parse_args()
|
||||
|
||||
with open("config.yaml", "rb") as config_file:
|
||||
config = yaml.load(config_file)
|
||||
|
||||
init_db()
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
else:
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
with open(args.config, 'rb') as config_file:
|
||||
config = yaml.load(config_file, Loader=yaml.SafeLoader)
|
||||
|
||||
engine = create_engine(config['SERVICE_DB'])
|
||||
db_session = scoped_session(sessionmaker(bind=engine))
|
||||
Base.query = db_session.query_property()
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
pnutpy.api.add_authorization_token(config['ACCESS_TOKEN'])
|
||||
|
||||
|
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
PyYAML
|
||||
pnutpy
|
||||
requests
|
||||
SQLAlchemy
|
||||
websocket-client
|
Loading…
Reference in a new issue