Skip to content

Commit f083f5e

Browse files
authored
The discord bot can now be ran as a docker container (#6)
* The discord bot can now be ran as a docker container * Fixed formatting * Add auto-restart to docker-compose.yaml
1 parent f02d3d6 commit f083f5e

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/venv/
2+
/.github/

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM python:3.12-alpine3.21
2+
WORKDIR /usr/src/app
3+
COPY . .
4+
RUN pip install -r requirements.txt
5+
CMD ["python", "-m", "amulet_discord_bot"]

amulet_discord_bot/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ async def on_raw_message_edit(self, payload: discord.RawMessageUpdateEvent) -> N
241241

242242
def main() -> None:
243243
parser = argparse.ArgumentParser(description="Run the Amulet Discord bot.")
244-
parser.add_argument("bot_token", type=str)
244+
parser.add_argument("bot_token", type=str, nargs="?")
245245
args = parser.parse_args()
246246

247247
intents = discord.Intents.default()
248248
intents.members = True
249249
intents.message_content = True
250250
client = AmuletBot(intents=intents)
251-
client.run(args.bot_token)
251+
client.run(args.bot_token or os.environ["BOT_TOKEN"])

docker-compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
amulet-discord-bot:
3+
image: amulet-discord-bot
4+
restart: unless-stopped
5+
environment:
6+
- BOT_TOKEN=${BOT_TOKEN}

0 commit comments

Comments
 (0)