Skip to content
Merged

Dev #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
with:
context: .
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
${{ env.IMAGE_NAME }}:${{ github.sha }}
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ RUN sed -i '/pt_BR.UTF-8/s/^# //g' /etc/locale.gen && \
# Copy the virtual environment from builder
COPY --from=builder /app/.venv /app/.venv

# Changes every commit; placed here so it doesn't invalidate the apt-get/locale
# layers above on every build.
ARG GIT_SHA=""
ENV GIT_SHA=${GIT_SHA}

# Copy project
COPY . /app/

Expand Down
2 changes: 2 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
- ${SOCKET_DIR}:/run/sockets
env_file:
- .env
environment:
- IMAGE_TAG=${IMAGE_TAG:-latest}
depends_on:
- db
restart: unless-stopped
Expand Down
11 changes: 11 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
import os
import tomllib
from dotenv import load_dotenv, find_dotenv
from django.contrib.messages import constants as messages

Expand All @@ -10,6 +11,15 @@

BUILD_ENV = os.getenv("BUILD_ENV", default="local")

with open(BASE_DIR / "pyproject.toml", "rb") as f:
APP_VERSION = tomllib.load(f)["project"]["version"]

# Set at image build time (see Dockerfile / .github/workflows/main.yml); empty outside CI builds.
GIT_SHA = os.getenv("GIT_SHA", "")[:7]

# Which image tag this container was deployed from (set via compose.yaml); "dev" or "latest".
IMAGE_TAG = os.getenv("IMAGE_TAG", "latest")

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("SECRET_KEY")

Expand Down Expand Up @@ -81,6 +91,7 @@
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"presente.context_processors.app_info",
],
},
},
Expand Down
9 changes: 9 additions & 0 deletions presente/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.conf import settings


def app_info(request):
return {
"app_version": settings.APP_VERSION,
"git_sha": settings.GIT_SHA,
"is_dev_build": settings.IMAGE_TAG == "dev",
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "presente"
version = "0.1.0"
version = "1.0.0"
description = "Sistema open source para gerenciamento de presença em atividades extra-classe do IFRN."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
3 changes: 2 additions & 1 deletion templates/presente/private_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@
<!--begin::To the end-->
<div class="float-end d-none d-sm-inline">
<a href="https://github.com/IFRN-SPP/presente" class="text-decoration-none text-reset" target="_blank">
<i class="bi bi-github"></i> Presente v1.0
<i class="bi bi-github"></i> Presente v{{ app_version }}{% if git_sha %} ({{ git_sha }}){% endif %}
</a>
{% if is_dev_build %}<span class="badge text-bg-warning ms-1">DEV</span>{% endif %}
</div>
<!--end::To the end-->
<!--begin::Copyright-->
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading