Skip to content

Commit 70f24e7

Browse files
authored
Add versioning support to Dockerfile and app footer (#35)
- Update Dockerfile to set APP_VERSION from build environment - Modify app.py to display the current version in the footer - Implement a check for tag presence in the build workflow
1 parent 984a265 commit 70f24e7

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/build_and_push_image.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ jobs:
2525
steps:
2626
- name: Checkout code
2727
uses: actions/checkout@v4
28+
29+
- name: Ensure tag present and set APP_VERSION
30+
run: |
31+
if [[ "${GITHUB_REF}" != refs/tags/* ]]; then
32+
echo "No tag found; failing build." && exit 1
33+
fi
34+
echo "APP_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
2835
2936
- name: Log in to the Container registry
3037
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
@@ -55,6 +62,8 @@ jobs:
5562
push: true
5663
tags: ${{ steps.meta.outputs.tags }}
5764
labels: ${{ steps.meta.outputs.labels }}
65+
build-args: |
66+
APP_VERSION=${{ env.APP_VERSION }}
5867
5968
- name: Generate artifact attestation
6069
uses: actions/attest-build-provenance@v2

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LABEL org.opencontainers.image.source="https://github.com/SASlabgroup/microSWIFT
55

66
# Set the working directory in the container
77
WORKDIR /app
8+
ARG APP_VERSION=DEV
9+
ENV APP_VERSION=${APP_VERSION}
810

911
# Copy the current directory contents into the container at /app
1012
COPY . /app

app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from dash import Dash, html, dcc, callback, Output, Input, no_update, ALL
24
import dash_bootstrap_components as dbc
35

@@ -24,6 +26,7 @@
2426
app.title = "Dashboard"
2527

2628
server = app.server
29+
APP_VERSION = os.getenv("APP_VERSION", "DEV")
2730

2831
# Set the default mission to the first mission in the list.
2932
all_missions = get_missions()
@@ -52,7 +55,7 @@
5255
html.Br(),
5356
html.Hr(),
5457
dbc.Card(id="latest_info", body=True),
55-
html.Footer("Version 0.8"),
58+
html.Footer(f"Version {APP_VERSION}"),
5659
]
5760
),
5861
width=3,

0 commit comments

Comments
 (0)