From 8ab883d0b95c697867f23e2a62d05e11071a2c83 Mon Sep 17 00:00:00 2001 From: Alexis Werefox Date: Fri, 27 Aug 2021 22:24:24 +0000 Subject: [PATCH] Initial commit. --- .gitignore | 4 +++ Dockerfile | 30 +++++++++++++++++++++++ README.md | 0 docker-compose.yml | 30 +++++++++++++++++++++++ requirements.txt | 3 +++ volumes/postgres/config/pgdb.key | 1 + volumes/python/lib/werefox_bot_runtime.py | 5 ++++ werefox_discord_bot.py | 5 ++++ 8 files changed, 78 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 requirements.txt create mode 100644 volumes/postgres/config/pgdb.key create mode 100644 volumes/python/lib/werefox_bot_runtime.py create mode 100644 werefox_discord_bot.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cacf56d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +volumes/python/data/** +volumes/postgres/pg_data/** +**/__pycache__/** +**/.pyc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8aaab04 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Pull Python alpine +FROM python:alpine +RUN apk --no-cache add \ + gcc \ + g++ \ + musl-dev \ + python3-dev \ + postgresql-dev \ + libxml2-dev + +# Create a new user to run as and set the working directory +ENV USER=werefox +ENV UID=991 +ENV GID=991 + +RUN addgroup -g "${GID}" werefox +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/home/werefox" \ + --ingroup "${USER}" \ + --uid "${UID}" \ + "${USER}" +USER werefox +WORKDIR /home/werefox/ +ENV PATH="${PATH}:/home/werefox/.local/bin" +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt +COPY werefox_discord_bot.py werefox_discord_bot.py +ENTRYPOINT [ "python", "werefox_discord_bot.py" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d010c74 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +--- +version: "3" +services: + werefox-discord-bot: + build: + context: . + dockerfile: Dockerfile + image: werefox-discord-bot:latest + container_name: wdb_container_service + restart: always + links: + - postgres + volumes: + - ./volumes/python/lib:/home/werefox/lib + - ./volumes/python/data:/home/werefox/data + postgres: + image: postgres:13 + restart: always + ports: + - 8131:8131 + volumes: + - ./volumes/postgres/pg_data:/var/lib/postgresql/data/pg_data + - ./volumes/postgres/config:/config + environment: + POSTGRES_PASSWORD_FILE: /config/pgdb.key + POSTGRES_DB: werefox_prod + POSTGRES_USER: werefox + POSTGRES_HOST: localhost + POSTGRES_PORT: 8131 + PGDATA: /var/lib/postgresql/data/pg_data diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bc6a4f9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +discord +psycopg2-binary +sqlalchemy diff --git a/volumes/postgres/config/pgdb.key b/volumes/postgres/config/pgdb.key new file mode 100644 index 0000000..1bcc091 --- /dev/null +++ b/volumes/postgres/config/pgdb.key @@ -0,0 +1 @@ +5Spgqd4MpNNRUoA8prJ4ddwSwAtZYq3f1LHK00O1NWSIV0yAXL2DhaKWnNaaJ5eo diff --git a/volumes/python/lib/werefox_bot_runtime.py b/volumes/python/lib/werefox_bot_runtime.py new file mode 100644 index 0000000..e9922dd --- /dev/null +++ b/volumes/python/lib/werefox_bot_runtime.py @@ -0,0 +1,5 @@ +#!/bin/python + +def run(): + print('This is a test.') + diff --git a/werefox_discord_bot.py b/werefox_discord_bot.py new file mode 100644 index 0000000..67d83bb --- /dev/null +++ b/werefox_discord_bot.py @@ -0,0 +1,5 @@ +#!/bin/python + +from lib.werefox_bot_runtime import run + +run()