Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Dockerfile-bot
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ COPY src/bot/pyproject.toml src/bot/pyproject.toml
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev --package eos-bot

RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*

COPY src/bot ./src/bot

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --package eos-bot

RUN --mount=source=../.git,target=.git,type=bind \
git rev-parse --short HEAD > /commit_hash.txt

RUN useradd -r -M botuser && chown -R botuser:botuser /bot
USER botuser

CMD ["uv", "run", "--frozen", "--no-cache", "--no-dev", "--package", "eos-bot", "python", "src/bot/main.py"]
ENTRYPOINT ["./src/bot/botrunner.sh"]
4 changes: 4 additions & 0 deletions src/bot/botrunner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

export GIT_HASH=$(cat /commit_hash.txt)
uv run --frozen --no-cache --no-dev --package eos-bot python src/bot/main.py
9 changes: 7 additions & 2 deletions src/bot/cogs/admin/healthchecks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import datetime
import logging
import os

import discord
from discord.ext import commands

logger = logging.getLogger(__name__)


def embed_hc(api, db, uptime):
def embed_hc(api, db, uptime, git_hash):
"""
Embedding for avatar change alerts.
"""
Expand All @@ -25,6 +26,7 @@ def embed_hc(api, db, uptime):
embed.add_field(name=api.get("message"), value=api.get("status_code"), inline=False)
embed.add_field(name=db.get("message"), value=db.get("status_code"), inline=False)
embed.add_field(name="Uptime:", value=uptime, inline=False)
embed.add_field(name="Commit Hash:", value=git_hash, inline=False)
return embed


Expand Down Expand Up @@ -77,7 +79,10 @@ async def hc(self, ctx: commands.Context) -> None:

uptime = self.get_uptime(self.bot.boot_time)

await ctx.reply(embed=embed_hc(api_info, db_info, uptime))
# Get commit hash from .env file
git_hash = os.getenv("GIT_HASH", default="Spam, Spam, Spam, Egg, and Spam!")

await ctx.reply(embed=embed_hc(api_info, db_info, uptime, git_hash))

def get_uptime(self, boot_time: datetime.datetime) -> str:
"""Get uptime from bot"""
Expand Down
Loading