Skip to content

Commit 409fe08

Browse files
committed
Display version information in test application
1 parent 2f9acc4 commit 409fe08

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.github/workflows/app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
with:
3737
context: .
3838
file: app/Dockerfile
39+
build-args: GIT_COMMIT_ID=${{ github.sha }}
3940
tags: ${{ steps.meta.outputs.tags }}
4041
labels: ${{ steps.meta.outputs.labels }}
4142
push: true

app/Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM phpdockerio/php:8.4-fpm
22
WORKDIR /application
33

4+
ARG GIT_COMMIT_ID=""
5+
46
# Install selected extensions and other stuff
57
RUN apt-get update \
68
&& apt-get -y --no-install-recommends install \
@@ -19,9 +21,11 @@ COPY app/src ./src
1921
COPY app/templates ./templates
2022
COPY src ./../src
2123

22-
RUN composer install --no-dev --no-scripts; \
23-
composer clear-cache; \
24-
composer dump-autoload --optimize --classmap-authoritative; \
25-
bin/console cache:warmup; \
26-
chown -R www-data:www-data ./var/; \
27-
chown -R www-data:www-data ./data/
24+
RUN composer install --no-dev --no-scripts \
25+
&& composer clear-cache \
26+
&& composer dump-autoload --optimize --classmap-authoritative \
27+
&& bin/console cache:warmup \
28+
&& chown -R www-data:www-data ./var/ \
29+
&& chown -R www-data:www-data ./data \
30+
&& echo "VERSION_COMMIT_ID=${GIT_COMMIT_ID}" >> .env \
31+
&& date +"VERSION_DATE=\"%Y-%m-%d %H:%M:%S\"" >> .env

app/config/packages/twig.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
],
1212
'debug' => '%kernel.debug%',
1313
'strict_variables' => '%kernel.debug%',
14+
'globals' => [
15+
'VERSION_COMMIT_ID' => '%env(default::VERSION_COMMIT_ID)%',
16+
'VERSION_DATE' => '%env(default::VERSION_DATE)%',
17+
],
1418
]);
1519
};

app/templates/base.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@
2424
<main>
2525
{% block body %}{% endblock %}
2626
</main>
27+
{% if VERSION_COMMIT_ID %}
28+
<footer>
29+
Version: <a href="https://github.com/scheb/2fa/commit/{{ VERSION_COMMIT_ID }}">{{ VERSION_COMMIT_ID|slice(0, 7) }}</a>, Build: {{ VERSION_DATE }}
30+
</footer>
31+
{% endif %}
2732
</body>
2833
</html>

0 commit comments

Comments
 (0)