Modif docker + ajout de la fonction de text aléatoire
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -12,7 +12,12 @@ RUN npm install
|
|||||||
# Copie des fichiers source
|
# Copie des fichiers source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build de l'application (sans définir d'URL spécifique)
|
# Argument de build pour l'URL de l'API
|
||||||
|
ARG VITE_TEXTS_API_URL
|
||||||
|
ENV VITE_TEXTS_API_URL=${VITE_TEXTS_API_URL}
|
||||||
|
|
||||||
|
# Build de l'application
|
||||||
|
RUN echo "Building with VITE_TEXTS_API_URL=$VITE_TEXTS_API_URL"
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Étape de production avec Nginx
|
# Étape de production avec Nginx
|
||||||
@@ -21,10 +26,6 @@ FROM nginx:alpine
|
|||||||
# Copie des fichiers buildés depuis l'étape précédente
|
# Copie des fichiers buildés depuis l'étape précédente
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# Copie du script de configuration de l'API
|
|
||||||
COPY 30-api-config.sh /docker-entrypoint.d/30-api-config.sh
|
|
||||||
RUN chmod +x /docker-entrypoint.d/30-api-config.sh
|
|
||||||
|
|
||||||
# Exposition explicite du port utilisé par Nginx
|
# Exposition explicite du port utilisé par Nginx
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
|||||||
1
backend/.env
Normal file
1
backend/.env
Normal file
@@ -0,0 +1 @@
|
|||||||
|
PORT=3000
|
||||||
@@ -21,7 +21,7 @@ app.use(cors())
|
|||||||
app.use(express.json())
|
app.use(express.json())
|
||||||
|
|
||||||
// Chemin vers le dossier texts (dossier parent)
|
// Chemin vers le dossier texts (dossier parent)
|
||||||
const TEXTS_DIR = process.env.TEXTS_PATH || path.join(__dirname, '..', 'texts')
|
const TEXTS_DIR = process.env.TEXTS_PATH || "C:\\Users\\paulf\\Documents\\texts"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service pour scanner et charger les textes depuis le dossier texts/
|
* Service pour scanner et charger les textes depuis le dossier texts/
|
||||||
@@ -322,6 +322,15 @@ class TextService {
|
|||||||
categories: categories.size
|
categories: categories.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getRandomText() {
|
||||||
|
const allTexts = await this.scanTexts()
|
||||||
|
if (allTexts.length === 0) {
|
||||||
|
throw new Error('Aucun texte disponible')
|
||||||
|
}
|
||||||
|
const randomIndex = Math.floor(Math.random() * allTexts.length)
|
||||||
|
return allTexts[randomIndex]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instance du service
|
// Instance du service
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Service pour communiquer avec l'API backend des textes
|
* Service pour communiquer avec l'API backend des textes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const API_BASE_URL = 'VITE_TEXTS_API_URL_PLACEHOLDER'
|
const API_BASE_URL = import.meta.env.VITE_TEXTS_API_URL || 'http://localhost:3000/api'
|
||||||
|
|
||||||
export class TextService {
|
export class TextService {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
25
truenas-build.yml
Normal file
25
truenas-build.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
api:
|
||||||
|
image: elpoyo/patois-api:latest
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- '52000:3000'
|
||||||
|
environment:
|
||||||
|
- PORT=3000
|
||||||
|
- TEXTS_PATH=/app/texts
|
||||||
|
- NODE_ENV=production
|
||||||
|
volumes:
|
||||||
|
- /mnt/Data/configs/patois:/app/texts
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
args:
|
||||||
|
- VITE_TEXTS_API_URL=https://patois.lagaudiere.uk/api
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- '52001:80'
|
||||||
|
depends_on:
|
||||||
|
- api
|
||||||
Reference in New Issue
Block a user