9 Commits

Author SHA1 Message Date
gitea-actions
838378a409 chore: bump version to v0.1.28
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
Build & Push Docker Image / build (push) Successful in 32s
2026-04-08 14:11:09 +00:00
Matthieu
95c90a258f feat(frontend) : add database info section and form field
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 16:11:00 +02:00
Matthieu
20d6dcea45 feat(i18n) : add database section translations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 16:11:00 +02:00
Matthieu
1cb2ff2130 feat(frontend) : add DatabaseInfo type and service
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 16:11:00 +02:00
Matthieu
df755d521c feat : add DatabaseInfo API resource and provider
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 16:11:00 +02:00
Matthieu
0019b5987d feat : add DatabaseService for PostgreSQL metrics
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 16:11:00 +02:00
Matthieu
41d6405872 feat(entity) : add databaseName field to Environment
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 16:11:00 +02:00
gitea-actions
e0ab5b5961 chore: bump version to v0.1.27
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
Build & Push Docker Image / build (push) Successful in 20s
2026-04-08 09:29:45 +00:00
Matthieu
560734d72c Revert "fix : resolve Docker port conflicts and fix var/ permissions on install"
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
This reverts commit 123d9b306f.
2026-04-08 11:29:38 +02:00
15 changed files with 362 additions and 15 deletions

View File

@@ -1,2 +1,2 @@
parameters:
app.version: '0.1.26'
app.version: '0.1.28'

View File

@@ -32,7 +32,7 @@ services:
depends_on:
- db
ports:
- "3005:3003"
- "3003:3003"
restart: unless-stopped
nginx:
image: nginx:1.27-alpine
@@ -47,7 +47,7 @@ services:
restart: unless-stopped
db:
image: postgres:16-alpine
command: -p ${POSTGRES_PORT:-5437}
command: -p ${POSTGRES_PORT:-5436}
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
@@ -55,7 +55,7 @@ services:
volumes:
- pg_data:/var/lib/postgresql/data
ports:
- "${POSTGRES_PORT:-5437}:${POSTGRES_PORT:-5437}"
- "${POSTGRES_PORT:-5436}:${POSTGRES_PORT:-5436}"
restart: unless-stopped
volumes:
pg_data:

View File

@@ -141,6 +141,20 @@
"ports": "Ports",
"noData": "Aucune donnee disponible"
},
"database": {
"title": "Base de donnees",
"status": "Statut",
"connected": "Connecte",
"unreachable": "Injoignable",
"name": "Base",
"size": "Taille",
"tableCount": "Tables",
"activeConnections": "Connexions",
"cacheHitRatio": "Cache hit",
"largestTable": "Plus grosse table",
"formLabel": "Nom de la base",
"formHint": "Ex : coltura"
},
"deploy": {
"button": "Deployer",
"title": "Deployer une version",

View File

@@ -4,8 +4,8 @@ import { getApplication, updateApplication, deleteApplication } from '~/services
import { createEnvironment, updateEnvironment, deleteEnvironment, toggleMaintenance } from '~/services/environments'
import type { DeployResult } from '~/services/dto/deploy'
import { getAvailableTags, deploy } from '~/services/deploy'
import type { EnvironmentHealth } from '~/services/dto/dashboard'
import { getEnvironmentHealth } from '~/services/dashboard'
import type { EnvironmentHealth, DatabaseInfo } from '~/services/dto/dashboard'
import { getEnvironmentHealth, getDatabaseInfo } from '~/services/dashboard'
import type { LogOutput } from '~/services/dto/logs'
import { getDockerLogs, getSymfonyLog } from '~/services/logs'
@@ -31,6 +31,9 @@ const deployResult = ref<DeployResult | null>(null)
const healthByEnvId = ref<Record<number, EnvironmentHealth>>({})
const loadingHealth = ref(false)
// Database info per env
const dbInfoByEnvId = ref<Record<number, DatabaseInfo>>({})
// Log modals
const showLogModal = ref(false)
const logContent = ref('')
@@ -54,6 +57,7 @@ const envForm = ref<EnvironmentWrite>({
deployScriptPath: '',
maintenanceFilePath: '',
appUrl: '',
databaseName: '',
logFiles: [],
})
const isSubmittingEnv = ref(false)
@@ -66,6 +70,7 @@ async function loadApplication() {
loading.value = false
}
loadHealthData()
loadDatabaseData()
}
// Application edit
@@ -103,7 +108,7 @@ async function handleDeleteApp() {
// Environment CRUD
function openCreateEnvModal() {
editingEnvId.value = null
envForm.value = { name: '', containerName: '', deployScriptPath: '', maintenanceFilePath: '', appUrl: '', logFiles: [] }
envForm.value = { name: '', containerName: '', deployScriptPath: '', maintenanceFilePath: '', appUrl: '', databaseName: '', logFiles: [] }
showEnvModal.value = true
}
@@ -115,6 +120,7 @@ function openEditEnvModal(env: Environment) {
deployScriptPath: env.deployScriptPath,
maintenanceFilePath: env.maintenanceFilePath,
appUrl: env.appUrl ?? '',
databaseName: env.databaseName ?? '',
logFiles: env.logFiles.map(lf => ({ label: lf.label, path: lf.path })),
}
showEnvModal.value = true
@@ -215,6 +221,20 @@ async function loadHealthData() {
}
}
async function loadDatabaseData() {
if (!application.value?.environments?.length) return
const promises = application.value.environments.map(async (env) => {
if (!env.databaseName) return
try {
const info = await getDatabaseInfo(env.id!)
dbInfoByEnvId.value[env.id!] = info
} catch {
// silently ignore — no database configured or unreachable
}
})
await Promise.all(promises)
}
function formatUptime(startedAt: string): string {
if (!startedAt) return '-'
const start = new Date(startedAt)
@@ -471,6 +491,50 @@ onMounted(loadApplication)
</div>
</div>
</div>
<!-- Database info -->
<div v-if="dbInfoByEnvId[env.id!]" class="mt-4 border-t border-neutral-200 py-3">
<p class="text-sm font-bold uppercase tracking-wider mb-2">{{ t('environments.database.title') }}</p>
<div class="grid grid-cols-2 sm:grid-cols-6 gap-3">
<div>
<p class="text-xs text-neutral-400">{{ t('environments.database.status') }}</p>
<span
class="inline-block rounded-full px-2.5 py-0.5 text-xs font-semibold mt-1"
:class="dbInfoByEnvId[env.id!].connected
? 'bg-green-100 text-green-700'
: 'bg-red-100 text-red-700'"
>
{{ dbInfoByEnvId[env.id!].connected
? t('environments.database.connected')
: t('environments.database.unreachable') }}
</span>
</div>
<div>
<p class="text-xs text-neutral-400">{{ t('environments.database.name') }}</p>
<p class="text-sm font-mono text-neutral-800 mt-1">{{ dbInfoByEnvId[env.id!].name }}</p>
</div>
<div>
<p class="text-xs text-neutral-400">{{ t('environments.database.size') }}</p>
<p class="text-sm text-neutral-800 mt-1">{{ dbInfoByEnvId[env.id!].size || '-' }}</p>
</div>
<div>
<p class="text-xs text-neutral-400">{{ t('environments.database.tableCount') }}</p>
<p class="text-sm text-neutral-800 mt-1">{{ dbInfoByEnvId[env.id!].tableCount }}</p>
</div>
<div>
<p class="text-xs text-neutral-400">{{ t('environments.database.activeConnections') }}</p>
<p class="text-sm text-neutral-800 mt-1">{{ dbInfoByEnvId[env.id!].activeConnections }}</p>
</div>
<div>
<p class="text-xs text-neutral-400">{{ t('environments.database.cacheHitRatio') }}</p>
<p class="text-sm text-neutral-800 mt-1">{{ dbInfoByEnvId[env.id!].cacheHitRatio }}%</p>
</div>
</div>
<p v-if="dbInfoByEnvId[env.id!].largestTable && dbInfoByEnvId[env.id!].largestTable !== '-'" class="text-xs text-neutral-500 mt-2">
{{ t('environments.database.largestTable') }} : <span class="font-mono">{{ dbInfoByEnvId[env.id!].largestTable }}</span>
</p>
</div>
<div class="flex justify-center gap-4 mt-4">
<MalioButton
:label="t('environments.editButton')"
@@ -577,6 +641,12 @@ onMounted(loadApplication)
:label="t('environments.form.appUrl')"
groupClass="mt-0"
/>
<MalioInputText
v-model="envForm.databaseName"
:label="t('environments.database.formLabel')"
:hint="t('environments.database.formHint')"
groupClass="mt-0"
/>
</div>
<!-- Log files -->

View File

@@ -1,4 +1,4 @@
import type { DashboardResponse, EnvironmentHealth } from './dto/dashboard'
import type { DashboardResponse, EnvironmentHealth, DatabaseInfo } from './dto/dashboard'
export function getDashboard(): Promise<DashboardResponse> {
return useApi().get<DashboardResponse>('/dashboard', undefined, {
@@ -11,3 +11,9 @@ export function getEnvironmentHealth(envId: number): Promise<EnvironmentHealth>
toast: false,
})
}
export function getDatabaseInfo(envId: number): Promise<DatabaseInfo> {
return useApi().get<DatabaseInfo>(`/environments/${envId}/database`, undefined, {
toast: false,
})
}

View File

@@ -12,6 +12,7 @@ type Environment = {
deployScriptPath: string
maintenanceFilePath: string
appUrl?: string
databaseName?: string
logFiles: LogFile[]
maintenance: boolean
}
@@ -22,6 +23,7 @@ type EnvironmentWrite = {
deployScriptPath: string
maintenanceFilePath: string
appUrl?: string
databaseName?: string
logFiles: LogFile[]
}

View File

@@ -22,6 +22,16 @@ type PortMapping = {
protocol: string
}
type DatabaseInfo = {
connected: boolean
name: string
size: string
tableCount: number
activeConnections: number
cacheHitRatio: number
largestTable: string
}
type EnvironmentHealth = {
status: string
version: string

View File

@@ -5,6 +5,6 @@ APP_USER=www-data
POSTGRES_DB=central
POSTGRES_USER=root
POSTGRES_PASSWORD=root
POSTGRES_PORT=5437
POSTGRES_PORT=5436
XDEBUG_CLIENT_HOST=host.docker.internal
HOST_APPS_PATH=/home/user/workspace

View File

@@ -81,7 +81,7 @@ RUN mkdir -p /var/www/.composer/cache/vcs \
ENV COMPOSER_HOME=/var/www/.composer
# Création de la structure du projet
RUN mkdir -p /var/www/html/LOG /var/www/html/var/cache /var/www/html/var/log
RUN mkdir /var/www/html/LOG
###> User ###
ARG CURRENT_UID

View File

@@ -43,11 +43,7 @@ install: composer-install cache-clear node-use build-nuxtJS migration-migrate
# Supprime tout est réinstalle tout (Attention ça supprime la bdd aussi)
reset: delete_built_dir remove_orphans build-without-cache start wait install
fix-permissions:
$(EXEC_PHP_ROOT) mkdir -p var/cache var/log
$(EXEC_PHP_ROOT) chown -R $(APP_USER):$(APP_USER) var/
composer-install: fix-permissions
composer-install:
$(EXEC_PHP) composer install
$(SYMFONY_CONSOLE) lexik:jwt:generate-keypair --skip-if-exists

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260408135722 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE environment ADD database_name VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE environment DROP database_name');
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\ApiResource;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\State\DatabaseInfoProvider;
#[ApiResource(
operations: [
new Get(
uriTemplate: '/environments/{id}/database',
security: "is_granted('ROLE_ADMIN')",
provider: DatabaseInfoProvider::class,
),
],
)]
final class DatabaseInfo
{
public bool $connected = false;
public string $name = '';
public string $size = '';
public int $tableCount = 0;
public int $activeConnections = 0;
public float $cacheHitRatio = 0.0;
public string $largestTable = '';
}

View File

@@ -73,6 +73,10 @@ class Environment
#[Groups(['env:read', 'env:write', 'app:detail'])]
private ?string $appUrl = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['env:read', 'env:write', 'app:detail'])]
private ?string $databaseName = null;
#[ORM\ManyToOne(targetEntity: Application::class, inversedBy: 'environments')]
#[ORM\JoinColumn(nullable: false)]
private ?Application $application = null;
@@ -155,6 +159,18 @@ class Environment
return $this;
}
public function getDatabaseName(): ?string
{
return $this->databaseName;
}
public function setDatabaseName(?string $databaseName): static
{
$this->databaseName = $databaseName;
return $this;
}
public function getApplication(): ?Application
{
return $this->application;

View File

@@ -0,0 +1,124 @@
<?php
declare(strict_types=1);
namespace App\Service;
use Doctrine\DBAL\Connection;
final class DatabaseService
{
public function __construct(
private readonly Connection $connection,
) {}
/**
* @return array{connected: bool, name: string, size: string, tableCount: int, activeConnections: int, cacheHitRatio: float, largestTable: string}
*/
public function getDatabaseInfo(string $databaseName): array
{
$fallback = [
'connected' => false,
'name' => $databaseName,
'size' => '',
'tableCount' => 0,
'activeConnections' => 0,
'cacheHitRatio' => 0.0,
'largestTable' => '',
];
try {
// Check database exists
$exists = $this->connection->fetchOne(
'SELECT 1 FROM pg_database WHERE datname = :dbname',
['dbname' => $databaseName]
);
if (!$exists) {
return $fallback;
}
// Database size
$sizeBytes = (int) $this->connection->fetchOne(
'SELECT pg_database_size(:dbname)',
['dbname' => $databaseName]
);
$size = $this->formatBytes($sizeBytes);
// Table count
$tableCount = (int) $this->connection->fetchOne(
"SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_catalog = :dbname",
['dbname' => $databaseName]
);
// Active connections
$activeConnections = (int) $this->connection->fetchOne(
'SELECT count(*) FROM pg_stat_activity WHERE datname = :dbname',
['dbname' => $databaseName]
);
// Cache hit ratio
$cacheHitRatio = (float) ($this->connection->fetchOne(
'SELECT round(100.0 * sum(blks_hit) / nullif(sum(blks_hit + blks_read), 0), 2) FROM pg_stat_database WHERE datname = :dbname',
['dbname' => $databaseName]
) ?? 0);
// Largest table — requires querying the target database catalog
$largestTable = $this->fetchLargestTable($databaseName);
return [
'connected' => true,
'name' => $databaseName,
'size' => $size,
'tableCount' => $tableCount,
'activeConnections' => $activeConnections,
'cacheHitRatio' => $cacheHitRatio,
'largestTable' => $largestTable,
];
} catch (\Throwable) {
return $fallback;
}
}
private function fetchLargestTable(string $databaseName): string
{
try {
$row = $this->connection->fetchAssociative(
"SELECT relname, pg_total_relation_size(c.oid) as total_size
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = 'public' AND c.relkind = 'r'
AND c.relowner = (SELECT oid FROM pg_roles WHERE rolname = current_user)
ORDER BY pg_total_relation_size(c.oid) DESC
LIMIT 1"
);
if (!$row) {
return '-';
}
return $row['relname'] . ' (' . $this->formatBytes((int) $row['total_size']) . ')';
} catch (\Throwable) {
return '-';
}
}
private function formatBytes(int $bytes): string
{
if ($bytes < 1024) {
return $bytes . ' B';
}
$units = ['KB', 'MB', 'GB', 'TB'];
$value = (float) $bytes;
foreach ($units as $unit) {
$value /= 1024;
if ($value < 1024) {
return round($value, 1) . ' ' . $unit;
}
}
return round($value, 1) . ' TB';
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\ApiResource\DatabaseInfo;
use App\Repository\EnvironmentRepository;
use App\Service\DatabaseService;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
final readonly class DatabaseInfoProvider implements ProviderInterface
{
public function __construct(
private EnvironmentRepository $environmentRepository,
private DatabaseService $databaseService,
) {}
public function provide(Operation $operation, array $uriVariables = [], array $context = []): DatabaseInfo
{
$id = $uriVariables['id'] ?? null;
$environment = $id ? $this->environmentRepository->find($id) : null;
if (null === $environment) {
throw new NotFoundHttpException(sprintf('Environment "%s" not found.', $id));
}
$databaseName = $environment->getDatabaseName();
if (null === $databaseName || '' === $databaseName) {
throw new NotFoundHttpException('No database configured for this environment.');
}
$info = $this->databaseService->getDatabaseInfo($databaseName);
$dto = new DatabaseInfo();
$dto->connected = $info['connected'];
$dto->name = $info['name'];
$dto->size = $info['size'];
$dto->tableCount = $info['tableCount'];
$dto->activeConnections = $info['activeConnections'];
$dto->cacheHitRatio = $info['cacheHitRatio'];
$dto->largestTable = $info['largestTable'];
return $dto;
}
}