Display git commit sha in footer
This commit is contained in:
parent
88f3c455ff
commit
11ceec343d
4 changed files with 24 additions and 1 deletions
10
Dockerfile
10
Dockerfile
|
@ -1,3 +1,12 @@
|
|||
FROM ubuntu:latest as git
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y git \
|
||||
&& mkdir /app
|
||||
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
RUN git rev-parse HEAD | tee /version
|
||||
|
||||
FROM python:3.8.5-slim
|
||||
|
||||
RUN apt-get update \
|
||||
|
@ -13,6 +22,7 @@ COPY docker ./docker/
|
|||
COPY blog ./blog/
|
||||
COPY attachments ./attachments/
|
||||
COPY articles ./articles/
|
||||
COPY --from=git /version /app/.version
|
||||
|
||||
ENV SECRET_KEY "changeme"
|
||||
ENV DEBUG "false"
|
||||
|
|
|
@ -21,3 +21,14 @@ def date_format(request):
|
|||
if request.path in IGNORED_PATHS:
|
||||
return {}
|
||||
return {"CUSTOM_ISO": r"Y-m-d\TH:i:sO"}
|
||||
|
||||
|
||||
def git_version(request):
|
||||
if request.path in IGNORED_PATHS:
|
||||
return {}
|
||||
try:
|
||||
with open("/app/.version") as f:
|
||||
version = f.read().strip()[:8]
|
||||
except FileNotFoundError:
|
||||
version = "latest"
|
||||
return {"git_version": version}
|
||||
|
|
|
@ -49,7 +49,8 @@
|
|||
This blog and all articles by Gabriel Augendre are licensed under the
|
||||
<a href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0 International License</a>.
|
||||
Code blocks by Gabriel Augendre are licensed under the
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GENERAL PUBLIC LICENSE version 3</a>.
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GENERAL PUBLIC LICENSE version 3</a>.<br>
|
||||
Currently deployed version: {{ git_version }}
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
|
|
@ -99,6 +99,7 @@ TEMPLATES = [
|
|||
"articles.context_processors.pages",
|
||||
"articles.context_processors.drafts_count",
|
||||
"articles.context_processors.date_format",
|
||||
"articles.context_processors.git_version",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
Reference in a new issue