Skip to content

Commit b0d7ada

Browse files
committed
Switch to using the git_sha dockerfile arg for version fetching
This also entrily removes the need for having git as a dependanncy in the image
1 parent 73c59c6 commit b0d7ada

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
FROM python:3.9-slim
22

3-
RUN apt-get update && apt-get -y install git
4-
53
# Set pip to have cleaner logs and no saved cache
64
ENV PIP_NO_CACHE_DIR=false \
75
PIPENV_IGNORE_VIRTUALENVS=1 \

bot/cogs/utilities.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from asyncio import sleep
22
from pathlib import Path
33
import random
4-
import subprocess
54
from typing import Optional
65

76
from discord import Colour, Embed
@@ -129,14 +128,9 @@ async def after_create_reminder() -> None:
129128
await ctx.send(msg)
130129

131130
@command(brief="Returns Friendo's Version")
132-
async def version(self, ctx: Context) -> str:
131+
async def version(self, ctx: Context) -> None:
133132
"""Creates a version number from settings.VERSION and most recent commit hash."""
134-
commit_hash = (subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("ascii"))
135-
msg = f"Version is {settings.VERSION}{commit_hash[-4:]}"
136-
137-
await ctx.send(msg)
138-
139-
return msg
133+
await ctx.send(f"Version is {settings.VERSION}+{settings.GIT_SHA}")
140134

141135
@command(brief="[number] [unit (seconds/minutes/hours)] [reason for reminder]", aliases=["remind"])
142136
async def reminder(self, ctx: Context, time: str, period: str = "minutes", *, reason: str = None) -> None:

bot/settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
FRIENDO_API_PASS = environ.get("FRIENDO_API_PASS")
2727
FRIENDO_API_URL = environ.get("FRIENDO_API_URL", "http://dev.friendo.dev/api/")
2828

29+
GIT_SHA = environ.get("GIT_SHA", "development")
30+
2931
log.info(f"Using {FRIENDO_API_URL} for backend...")
3032

3133
VERSION = "1.2"

0 commit comments

Comments
 (0)