Dockerfile
This commit is contained in:
1 parent
ffc7dc68fe
commit
7245893715
2 files changed
+32
-11
No files matched your search
+13
-6
@@ -1,25 +1,32 @@
|
||||
# Étape 1 : Build & Generation
|
||||
FROM node:22-alpine AS builder
|
||||
FROM node:22-bookworm-slim AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Installation des dépendances système nécessaires pour Prisma sur Debian
|
||||
RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY package*.json ./
|
||||
COPY prisma ./prisma/
|
||||
|
||||
# On installe TOUTES les dépendances (y compris prisma)
|
||||
RUN npm ci
|
||||
|
||||
# On génère le client Prisma (important pour Alpine)
|
||||
# On génère le client Prisma
|
||||
RUN npx prisma generate
|
||||
|
||||
COPY . .
|
||||
|
||||
# Si tu as du TypeScript à compiler
|
||||
# RUN npm run build
|
||||
|
||||
# Étape 2 : Runtime
|
||||
FROM node:22-alpine
|
||||
FROM node:22-bookworm-slim
|
||||
WORKDIR /app
|
||||
|
||||
# Installation des utilitaires pour communiquer avec l'hôte Debian
|
||||
RUN apt-get update && apt-get install -y \
|
||||
systemd \
|
||||
dbus \
|
||||
openssl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Récupération de la BDD (et autres) depuis Coolify au build avec valeurs par défaut
|
||||
ARG CORS_ORIGIN="https://logai.orionis-home.fr"
|
||||
ENV CORS_ORIGIN=$CORS_ORIGIN
|
||||
|
||||
@@ -114,28 +114,42 @@ export class LogTracker {
|
||||
args = ['-Command', 'Get-Service | Select-Object Name, Status | ConvertTo-Json'];
|
||||
} else {
|
||||
cmd = 'systemctl';
|
||||
args = ['list-units', '--type=service', '--all'];
|
||||
args = ['list-units', '--type=service', '--all', '--no-legend', '--no-pager'];
|
||||
}
|
||||
|
||||
const proc = spawn(cmd, args);
|
||||
let data = '';
|
||||
let errorData = '';
|
||||
|
||||
proc.stdout.on('data', (chunk) => data += chunk);
|
||||
proc.on('close', () => {
|
||||
proc.stderr.on('data', (chunk) => errorData += chunk);
|
||||
|
||||
proc.on('close', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error(`❌ systemctl failed with code ${code}: ${errorData}`);
|
||||
resolve([]);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (process.platform === 'win32') {
|
||||
const svcs = JSON.parse(data);
|
||||
resolve(svcs.map((s: any) => ({ name: s.Name, state: s.Status === 4 ? 'running' : 'stopped' })));
|
||||
} else {
|
||||
// Basic parsing for systemctl (very naive)
|
||||
const lines = data.split('\n').filter(l => l.includes('.service'));
|
||||
// Robust parsing for systemctl output
|
||||
const lines = data.split('\n').filter(l => l.trim().length > 0);
|
||||
const svcs = lines.map(l => {
|
||||
const parts = l.trim().split(/\s+/);
|
||||
return { name: parts[0], state: parts[3] === 'running' ? 'running' : 'stopped' };
|
||||
// format: unit load active sub description
|
||||
// example: cron.service loaded active running Regular background program processing daemon
|
||||
const name = parts[0];
|
||||
const state = parts[3] === 'running' ? 'running' : 'stopped';
|
||||
return { name, state };
|
||||
});
|
||||
resolve(svcs);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error("❌ Error parsing OS services:", e);
|
||||
resolve([]);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user