diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 8777194..517879c 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -72,7 +72,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=sha,format=short + type=sha,format=short,prefix= type=raw,value=latest,enable={{is_default_branch}} - name: Build and push Docker image @@ -83,6 +83,9 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + COMMIT_HASH=${{ github.sha }} + BUILD_DATE=${{ github.event.head_commit.timestamp }} cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max diff --git a/Dockerfile b/Dockerfile index 26b9320..c345b7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,6 +52,12 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ ENV NODE_ENV=production \ PORT=3000 +# Build arguments for version info +ARG COMMIT_HASH=unknown +ARG BUILD_DATE=unknown +ENV COMMIT_HASH=${COMMIT_HASH} +ENV BUILD_DATE=${BUILD_DATE} + # Use dumb-init to handle signals properly ENTRYPOINT ["dumb-init", "--"] diff --git a/public/index.html b/public/index.html index f47ca3f..bcc3dfd 100644 --- a/public/index.html +++ b/public/index.html @@ -467,6 +467,7 @@ Einstellungen +
diff --git a/public/js/main.js b/public/js/main.js index 61609a9..1ad10cd 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -2757,6 +2757,27 @@ async function loadSettings() { } } +/** + * Load and display version info + */ +async function loadVersionInfo() { + try { + const response = await fetch('/api/version'); + if (!response.ok) return; + + const versionData = await response.json(); + const versionEl = document.getElementById('versionInfo'); + + if (versionEl && versionData.commit) { + const shortHash = versionData.commit.substring(0, 7); + versionEl.textContent = shortHash !== 'dev' ? shortHash : 'dev'; + versionEl.title = `Commit: ${versionData.commit}\nBuild: ${versionData.buildDate}`; + } + } catch (error) { + console.log('Could not load version info:', error); + } +} + /** * Handle vacation days input change */ @@ -3781,6 +3802,7 @@ document.addEventListener('DOMContentLoaded', async () => { initializeFlatpickr(); initializeEventListeners(); await loadSettings(); // Load saved settings first + await loadVersionInfo(); // Load version info checkRunningTimer(); // Check if timer was running loadMonthlyView(); // Load monthly view by default }); diff --git a/server.js b/server.js index 65a4ae7..ff98015 100644 --- a/server.js +++ b/server.js @@ -499,6 +499,17 @@ app.get('/api/settings', (req, res) => { } }); +// Get version/commit info +app.get('/api/version', (req, res) => { + const commitHash = process.env.COMMIT_HASH || 'dev'; + const buildDate = process.env.BUILD_DATE || new Date().toISOString(); + + res.json({ + commit: commitHash, + buildDate: buildDate + }); +}); + // Start server app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`);