Added git hash as version number

This commit is contained in:
2025-11-28 11:48:29 +01:00
parent 35f773047d
commit 7f908157bf
6 changed files with 24 additions and 14 deletions

5
cntmanage/docker/build.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
GIT_HASH=$(git rev-parse --short HEAD)
echo "Building Flightslot version ${GIT_HASH}"
docker compose build --build-arg GIT_HASH=${GIT_HASH}

View File

@@ -22,6 +22,8 @@ services:
build:
context: ..
dockerfile: ./docker/flightslot.Dockerfile
args:
GIT_HASH:
image: flightslot:latest
container_name: tech-flightslot
restart: unless-stopped

View File

@@ -23,5 +23,5 @@ else
echo "👁️ Superuser ${DJANGO_SUPERUSER_USERNAME} created successfully ..."
fi
echo "🚀 Launching Flightslot..."
echo "🚀 Launching Flightslot version ${VERSION} ..."
exec "$@"

View File

@@ -4,7 +4,6 @@ FROM python:3.12 AS builder
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="${PATH}:/root/.local/bin"
RUN env
# Create build directory
WORKDIR /build
# Copy project files
@@ -14,28 +13,26 @@ RUN poetry update --no-interaction --no-ansi
# Build project
RUN poetry build
### STAGE 2 — Final image
### STAGE 2 — Final image ###
FROM python:3.12-slim AS deploy
# Create app run directory
WORKDIR /app
# Copy application custom static files
RUN mkdir -p static
COPY ./static/cantorair.jpg ./static
COPY ./static/cantorair_blue.jpg ./static
# Copy application custom templates for admin page
RUN mkdir -p /templates/admin
COPY ./templates/admin/* ./templates/admin/
# Copy and install application wheel package
COPY --from=builder /build/dist/*.whl ./
RUN pip install --no-cache-dir *.whl
RUN pip install gunicorn whitenoise
# Copy entryupoint bash script
COPY ./docker/entrypoint.sh ./
# Collect build number from build arg
ARG GIT_HASH
ENV VERSION=${GIT_HASH}
ENTRYPOINT ["/app/entrypoint.sh"]
# Command to be executed after entry point
CMD ["gunicorn", "cntmanage.wsgi:application", "--bind", "0.0.0.0:8000", "--timeout", "600"]

View File

@@ -15,6 +15,9 @@ from .admins.weekpref_adm import WeekPreferenceAdmin
from django.contrib.admin import AdminSite
from os import environ
# User website under /user/ URL
class FlightSlotUserSite(AdminSite):
site_header = "Flight Scheduler 🛫"
site_title = "Flight Scheduler 🛫"
@@ -28,13 +31,16 @@ class FlightSlotUserSite(AdminSite):
return app_list
# Register only user visible models
flightslot_user = FlightSlotUserSite(name="user_site")
# registra SOLO i modelli autorizzati
flightslot_user.register(WeekPreference, WeekPreferenceAdmin)
admin.site.site_header = "Flight Scheduler Admin 🛫"
admin.site.site_title = "Flight Scheduler Admin 🛫"
# Get version for debug purposes
ver: str = environ.get("VERSION", "dev")
# Register all visible models
admin.site.site_header = f"Flight Scheduler Admin 🛫 - ver.{ver}"
admin.site.site_title = f"Flight Scheduler Admin 🛫 - ver.{ver}"
admin.site.index_title = "Welcome to CantorAir Flight Scheduler Administrator Portal"
admin.site.register(Aircraft, AircraftAdmin)

View File

@@ -1,4 +1,4 @@
from django.forms import ModelChoiceField, TypedMultipleChoiceField, ModelMultipleChoiceField
from django.forms import ModelMultipleChoiceField
from django.contrib import admin, messages
from django.http import HttpRequest
from django.db.models.query import QuerySet, Q