From 4ce587371166ac31c82b1bda2d5cf8909367cbfd Mon Sep 17 00:00:00 2001 From: whitney Date: Thu, 16 May 2024 14:01:00 -0700 Subject: [PATCH] Dockerize PWSBot --- .gitignore | 2 +- pwsBot/Dockerfile | 10 +++++----- pwsBot/bot.py | 2 +- pwsBot/commands/__init__.py | 0 pwsBot/docker-compose.yml | 8 +++----- pwsBot/requirements.txt | 1 + 6 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 pwsBot/commands/__init__.py create mode 100644 pwsBot/requirements.txt diff --git a/.gitignore b/.gitignore index b94befc..1d9395b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ env/ pwsBot/commands/__pycache__/ pwsBot/resource/__pycache__/ -token.json +pwsBot/resource/token.json diff --git a/pwsBot/Dockerfile b/pwsBot/Dockerfile index 83abd87..e996efa 100644 --- a/pwsBot/Dockerfile +++ b/pwsBot/Dockerfile @@ -1,11 +1,11 @@ FROM python:3.11 -WORKDIR /discord +WORKDIR /app -COPY ./ /discord +COPY bot.py requirements.txt ./ +COPY resource/ ./resource +COPY commands/ ./commands -EXPOSE 3000 - -WORKDIR /discord +RUN pip install --no-cache-dir -r requirements.txt CMD [ "python", "bot.py" ] diff --git a/pwsBot/bot.py b/pwsBot/bot.py index 5d455d4..096ac22 100644 --- a/pwsBot/bot.py +++ b/pwsBot/bot.py @@ -15,7 +15,7 @@ pws_command_with_args_regex = r'/pws \S+(.*)' intents = get_intents() client = discord.Client(intents=intents) -client_token = get_token('../token.json') +client_token = get_token('resource/token.json') @client.event async def on_ready(): diff --git a/pwsBot/commands/__init__.py b/pwsBot/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pwsBot/docker-compose.yml b/pwsBot/docker-compose.yml index d283948..fe670b0 100644 --- a/pwsBot/docker-compose.yml +++ b/pwsBot/docker-compose.yml @@ -1,10 +1,8 @@ -version: "3" +version: "3.8" services: - website: - image: pwsBot:latest + pwsBot: + image: pwsbot:latest container_name: pwsBot build: . - ports: - - 8000:8000 diff --git a/pwsBot/requirements.txt b/pwsBot/requirements.txt new file mode 100644 index 0000000..446ed9b --- /dev/null +++ b/pwsBot/requirements.txt @@ -0,0 +1 @@ +discord.py==2.3.2 \ No newline at end of file