mirror of
https://github.com/wahyd4/links.git
synced 2026-08-08 21:04:53 +10:00
feat: add build time and version info to Docker image and page footer
Agent-Logs-Url: https://github.com/wahyd4/links/sessions/514d1f3d-d003-4f16-9a54-d221dba306f7 Co-authored-by: wahyd4 <836576+wahyd4@users.noreply.github.com>
This commit is contained in:
co-authored by
wahyd4
parent
6d9d08d132
commit
768ab6c5d8
@@ -60,6 +60,10 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
- name: Set build timestamp
|
||||
id: build_time
|
||||
run: echo "value=$(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
|
||||
|
||||
# Build and push main application image
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
@@ -72,6 +76,9 @@ jobs:
|
||||
ghcr.io/wahyd4/links:1.0.${{ github.run_number }}
|
||||
labels: |-
|
||||
${{ steps.meta.outputs.labels }}
|
||||
build-args: |-
|
||||
BUILD_TIME=${{ steps.build_time.outputs.value }}
|
||||
BUILD_VERSION=1.0.${{ github.run_number }}
|
||||
|
||||
- name: Deploy to Kubernetes
|
||||
uses: wahyd4/kubectl-helm-action@master
|
||||
|
||||
@@ -73,6 +73,10 @@ RUN rm -rf /tmp/.cache/uv ~/.npm ~/.cache \
|
||||
# Production stage - use Python 3.12 slim
|
||||
FROM python:3.12-slim AS production
|
||||
|
||||
# Build-time metadata
|
||||
ARG BUILD_TIME=""
|
||||
ARG BUILD_VERSION=""
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
@@ -81,6 +85,8 @@ ENV VIRTUAL_ENV=/app/.venv
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/app/.playwright
|
||||
ENV BUILD_TIME=${BUILD_TIME}
|
||||
ENV BUILD_VERSION=${BUILD_VERSION}
|
||||
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def build_info(request):
|
||||
return {
|
||||
'BUILD_TIME': getattr(settings, 'BUILD_TIME', ''),
|
||||
'BUILD_VERSION': getattr(settings, 'BUILD_VERSION', ''),
|
||||
}
|
||||
@@ -36,6 +36,7 @@ TEMPLATES = [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'core.context_processors.build_info',
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -207,6 +208,10 @@ R2_CUSTOM_DOMAIN = os.environ.get('R2_CUSTOM_DOMAIN')
|
||||
CRAWL4AI_API_URL = os.environ.get('CRAWL4AI_API_URL', 'https://crawl-api.junv.cc')
|
||||
CRAWL4AI_ENABLED = os.environ.get('CRAWL4AI_ENABLED', 'True').lower() in ('true', '1', 'yes')
|
||||
|
||||
# Build metadata (injected at Docker image build time)
|
||||
BUILD_TIME = os.environ.get('BUILD_TIME', '')
|
||||
BUILD_VERSION = os.environ.get('BUILD_VERSION', '')
|
||||
|
||||
# For debugging
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
|
||||
@@ -252,5 +252,10 @@
|
||||
});
|
||||
</script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
{% if BUILD_TIME %}
|
||||
<footer class="text-center text-gray-400 text-xs py-3 mt-4 border-t border-gray-100">
|
||||
Built at: {{ BUILD_TIME }} with ver: {{ BUILD_VERSION }}
|
||||
</footer>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user