Compare commits
6 Commits
upgrade/dj
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
ad9d55e986
|
|||
|
996ea628c7
|
|||
|
523b991493
|
|||
|
310c4fdd0b
|
|||
| 353a8a5697 | |||
| f1d3c88a45 |
@@ -8,7 +8,7 @@ COPY requirements.txt /app/
|
|||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
FROM python:3.15-rc-slim-trixie
|
FROM python:3.15-rc-slim-trixie
|
||||||
RUN useradd -m -r appuser && \
|
RUN useradd -m -r -u 99 appuser && \
|
||||||
mkdir /app && \
|
mkdir /app && \
|
||||||
chown -R appuser /app
|
chown -R appuser /app
|
||||||
|
|
||||||
|
|||||||
5
VorgabenUI/context_processors.py
Normal file
5
VorgabenUI/context_processors.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
def version(request):
|
||||||
|
return {'version': settings.VERSION}
|
||||||
@@ -23,6 +23,9 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = os.environ.get('DEBUG', 'True').lower() in ('true', '1', 'yes', 'on')
|
DEBUG = os.environ.get('DEBUG', 'True').lower() in ('true', '1', 'yes', 'on')
|
||||||
|
|
||||||
|
# Application version (from ConfigMap)
|
||||||
|
VERSION = os.environ.get('VERSION', '0.0.0')
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = os.environ.get('VORGABENUI_SECRET')
|
SECRET_KEY = os.environ.get('VORGABENUI_SECRET')
|
||||||
if not SECRET_KEY:
|
if not SECRET_KEY:
|
||||||
@@ -94,6 +97,7 @@ TEMPLATES = [
|
|||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
'VorgabenUI.context_processors.version',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ urlpatterns = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Serve media files (including cached diagrams)
|
# Serve media files (including cached diagrams)
|
||||||
|
# django.conf.urls.static.static() is a no-op when DEBUG=False,
|
||||||
|
# so we wire up the serve view directly for media files.
|
||||||
|
from django.views.static import serve
|
||||||
|
urlpatterns += [
|
||||||
|
re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
|
||||||
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
||||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ data:
|
|||||||
STATIC_URL: "/static/"
|
STATIC_URL: "/static/"
|
||||||
MEDIA_URL: "/media/"
|
MEDIA_URL: "/media/"
|
||||||
|
|
||||||
|
# Application Version
|
||||||
|
VERSION: "0.987"
|
||||||
|
|
||||||
# Database Configuration (for future use)
|
# Database Configuration (for future use)
|
||||||
# DATABASE_ENGINE: "django.db.backends.sqlite3"
|
# DATABASE_ENGINE: "django.db.backends.sqlite3"
|
||||||
# DATABASE_NAME: "/app/data/db.sqlite3"
|
# DATABASE_NAME: "/app/data/db.sqlite3"
|
||||||
|
|||||||
@@ -19,13 +19,15 @@ spec:
|
|||||||
initContainers:
|
initContainers:
|
||||||
- name: loader
|
- name: loader
|
||||||
image: git.baumann.gr/adebaumann/vui-data-loader:0.11
|
image: git.baumann.gr/adebaumann/vui-data-loader:0.11
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 99
|
||||||
command: [ "sh","-c","if [ ! -f /data/db.sqlite3 ] || [ ! -s /data/db.sqlite3 ]; then cp preload/preload.sqlite3 /data/db.sqlite3 && echo 'Database copied from preload'; else echo 'Existing database preserved'; fi" ]
|
command: [ "sh","-c","if [ ! -f /data/db.sqlite3 ] || [ ! -s /data/db.sqlite3 ]; then cp preload/preload.sqlite3 /data/db.sqlite3 && echo 'Database copied from preload'; else echo 'Existing database preserved'; fi" ]
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: data
|
- name: data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
containers:
|
containers:
|
||||||
- name: web
|
- name: web
|
||||||
image: git.baumann.gr/adebaumann/vui:0.983
|
image: git.baumann.gr/adebaumann/vui:0.987
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsUser: 99
|
runAsUser: 99
|
||||||
@@ -52,6 +54,11 @@ spec:
|
|||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
name: django-config
|
name: django-config
|
||||||
key: DJANGO_SETTINGS_MODULE
|
key: DJANGO_SETTINGS_MODULE
|
||||||
|
- name: VERSION
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: django-config
|
||||||
|
key: VERSION
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|||||||
@@ -219,7 +219,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6 text-right">
|
<div class="col-sm-6 text-right">
|
||||||
<p class="text-muted">Version {{ version|default:"0.983" }}</p>
|
<p class="text-muted">Version {{ version|default:"0.986" }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from .models import Referenz
|
from .models import Referenz
|
||||||
from abschnitte.utils import render_textabschnitte
|
from abschnitte.utils import render_textabschnitte
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
def tree(request):
|
def tree(request):
|
||||||
@@ -9,7 +10,7 @@ def tree(request):
|
|||||||
|
|
||||||
|
|
||||||
def detail(request, refid):
|
def detail(request, refid):
|
||||||
referenz_item = Referenz.objects.get_object_or_404(id=refid)
|
referenz_item = get_object_or_404(Referenz, id=refid)
|
||||||
referenz_item.erklaerung = render_textabschnitte(referenz_item.referenzerklaerung_set.order_by("order"))
|
referenz_item.erklaerung = render_textabschnitte(referenz_item.referenzerklaerung_set.order_by("order"))
|
||||||
referenz_item.children = list(referenz_item.get_descendants(include_self=True))
|
referenz_item.children = list(referenz_item.get_descendants(include_self=True))
|
||||||
for child in referenz_item.children:
|
for child in referenz_item.children:
|
||||||
|
|||||||
@@ -36,10 +36,15 @@ NEW_MAIN_VERSION=$(echo "$MAIN_VERSION + 0.001" | bc | sed 's/^\./0./')
|
|||||||
sed -i "s|image: git.baumann.gr/adebaumann/labhelper-data-loader:$LOADER_VERSION|image: git.baumann.gr/adebaumann/labhelper-data-loader:$NEW_LOADER_VERSION|" "$DEPLOYMENT_FILE"
|
sed -i "s|image: git.baumann.gr/adebaumann/labhelper-data-loader:$LOADER_VERSION|image: git.baumann.gr/adebaumann/labhelper-data-loader:$NEW_LOADER_VERSION|" "$DEPLOYMENT_FILE"
|
||||||
sed -i "s|image: git.baumann.gr/adebaumann/labhelper:$MAIN_VERSION|image: git.baumann.gr/adebaumann/labhelper:$NEW_MAIN_VERSION|" "$DEPLOYMENT_FILE"
|
sed -i "s|image: git.baumann.gr/adebaumann/labhelper:$MAIN_VERSION|image: git.baumann.gr/adebaumann/labhelper:$NEW_MAIN_VERSION|" "$DEPLOYMENT_FILE"
|
||||||
|
|
||||||
|
# Update the configmap version to match the main container
|
||||||
|
CONFIGMAP_FILE="argocd/configmap.yaml"
|
||||||
|
sed -i "s|VERSION: \"$MAIN_VERSION\"|VERSION: \"$NEW_MAIN_VERSION\"|" "$CONFIGMAP_FILE"
|
||||||
|
|
||||||
# Copy database
|
# Copy database
|
||||||
cp "$DB_SOURCE" "$DB_DEST"
|
cp "$DB_SOURCE" "$DB_DEST"
|
||||||
|
|
||||||
echo "Full deployment prepared:"
|
echo "Full deployment prepared:"
|
||||||
echo " Data loader: $LOADER_VERSION -> $NEW_LOADER_VERSION"
|
echo " Data loader: $LOADER_VERSION -> $NEW_LOADER_VERSION"
|
||||||
echo " Main container: $MAIN_VERSION -> $NEW_MAIN_VERSION"
|
echo " Main container: $MAIN_VERSION -> $NEW_MAIN_VERSION"
|
||||||
|
echo " ConfigMap VERSION: $NEW_MAIN_VERSION"
|
||||||
echo " Database copied to $DB_DEST"
|
echo " Database copied to $DB_DEST"
|
||||||
|
|||||||
@@ -23,5 +23,10 @@ NEW_VERSION=$(echo "$CURRENT_VERSION + 0.001" | bc | sed 's/^\./0./')
|
|||||||
# Update the deployment file (only the main container, not the data-loader)
|
# Update the deployment file (only the main container, not the data-loader)
|
||||||
sed -i "s|image: git.baumann.gr/adebaumann/vui:$CURRENT_VERSION|image: git.baumann.gr/adebaumann/vui:$NEW_VERSION|" "$DEPLOYMENT_FILE"
|
sed -i "s|image: git.baumann.gr/adebaumann/vui:$CURRENT_VERSION|image: git.baumann.gr/adebaumann/vui:$NEW_VERSION|" "$DEPLOYMENT_FILE"
|
||||||
|
|
||||||
|
# Update the configmap version to match the main container
|
||||||
|
CONFIGMAP_FILE="argocd/configmap.yaml"
|
||||||
|
sed -i "s|VERSION: \"$CURRENT_VERSION\"|VERSION: \"$NEW_VERSION\"|" "$CONFIGMAP_FILE"
|
||||||
|
|
||||||
echo "Partial deployment prepared:"
|
echo "Partial deployment prepared:"
|
||||||
echo " Main container: $CURRENT_VERSION -> $NEW_VERSION"
|
echo " Main container: $CURRENT_VERSION -> $NEW_VERSION"
|
||||||
|
echo " ConfigMap VERSION: $NEW_VERSION"
|
||||||
|
|||||||
Reference in New Issue
Block a user