diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 229d09f..c8cc49c 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -36,6 +36,10 @@ jobs: type=ref,event=branch type=raw,value=latest,enable={{is_default_branch}} + - name: Get build time + id: buildtime + run: echo "BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT + - name: Build and push Docker image uses: docker/build-push-action@v7 with: @@ -43,5 +47,7 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + BUILD_TIME=${{ steps.buildtime.outputs.BUILD_TIME }} cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max diff --git a/Dockerfile b/Dockerfile index bf2db1f..01b9334 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ COPY --from=dependencies /app/node_modules ./node_modules COPY . . ENV NODE_ENV=production +ENV BUILD_TIME=${BUILD_TIME} # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry @@ -63,6 +64,7 @@ WORKDIR /app ENV NODE_ENV=production ENV PORT=3000 ENV HOSTNAME="0.0.0.0" +ENV BUILD_TIME=${BUILD_TIME} # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 53a729b..bd9ac4e 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -1,6 +1,7 @@ import DatasetsList from "@/components/DatasetsList"; import CreateDatasetModal from "@/components/CreateDatasetModal"; import { AdminTokenForm } from "@/components/AdminTokenForm"; +import BuildInfo from "@/components/BuildInfo"; import { requireAdmin } from "@/lib/auth"; import { redirect } from "next/navigation"; import Link from "next/link"; @@ -30,6 +31,10 @@ export default async function AdminPage() { +
+ +
+

Datasets

diff --git a/src/components/BuildInfo.tsx b/src/components/BuildInfo.tsx new file mode 100644 index 0000000..e179031 --- /dev/null +++ b/src/components/BuildInfo.tsx @@ -0,0 +1,32 @@ +export default function BuildInfo() { + const buildTime = process.env.BUILD_TIME; + + if (!buildTime) { + return null; + } + + const buildDate = new Date(buildTime); + const now = new Date(); + const diffMs = now.getTime() - buildDate.getTime(); + + let timeAgo = ''; + const diffMins = Math.floor(diffMs / 60000); + const diffHours = Math.floor(diffMs / 3600000); + const diffDays = Math.floor(diffMs / 86400000); + + if (diffMins < 60) { + timeAgo = `${diffMins} minute${diffMins !== 1 ? 's' : ''} ago`; + } else if (diffHours < 24) { + timeAgo = `${diffHours} hour${diffHours !== 1 ? 's' : ''} ago`; + } else { + timeAgo = `${diffDays} day${diffDays !== 1 ? 's' : ''} ago`; + } + + return ( +
+

+ Build Time: {buildDate.toLocaleString()} ({timeAgo}) +

+
+ ); +}