mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
Merge branch 'refactoring' of ssh://git.v0id.ovh:5022/n3wt-innov/n3wt-school into refactoring
This commit is contained in:
@ -29,8 +29,16 @@ ENV NODE_ENV=production
|
|||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
COPY --from=builder /app/messages ./messages
|
COPY --from=builder /app/messages ./messages
|
||||||
|
COPY docker/entrypoint.sh /app/entrypoint.sh
|
||||||
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
RUN chown 1001:1001 -R /app
|
||||||
|
USER nextjs
|
||||||
|
ENV HOSTNAME="0.0.0.0"
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["node", "server.js"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|
||||||
|
|
||||||
# Final stage selection
|
# Final stage selection
|
||||||
FROM ${BUILD_MODE}
|
FROM ${BUILD_MODE}
|
||||||
|
|||||||
58
Front-End/docker/entrypoint.sh
Normal file
58
Front-End/docker/entrypoint.sh
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Configuration des chemins
|
||||||
|
CONFIG_FILE="/app/server.js"
|
||||||
|
TEMP_FILE="/app/server.tmp.js"
|
||||||
|
ENV_FILE="/app/.env"
|
||||||
|
|
||||||
|
# Fonction pour échapper les caractères spéciaux
|
||||||
|
escape_value() {
|
||||||
|
echo "$1" | sed 's/[\/&]/\\&/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copie initiale du fichier
|
||||||
|
cp $CONFIG_FILE $TEMP_FILE
|
||||||
|
|
||||||
|
# Lecture du fichier .env s'il existe
|
||||||
|
if [ -f "$ENV_FILE" ]; then
|
||||||
|
echo "📄 Lecture des variables depuis ${ENV_FILE}"
|
||||||
|
|
||||||
|
while IFS='=' read -r key value || [ -n "$key" ]; do
|
||||||
|
# Ignorer les lignes vides ou commentaires
|
||||||
|
case $key in
|
||||||
|
''|\#*) continue ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Nettoyage des variables
|
||||||
|
key=$(echo "$key" | tr -d ' ')
|
||||||
|
value=$(echo "$value" | tr -d '"' | tr -d "'")
|
||||||
|
|
||||||
|
# Vérifier si c'est une variable NEXT_PUBLIC
|
||||||
|
case $key in
|
||||||
|
NEXT_PUBLIC_*)
|
||||||
|
escaped_value=$(escape_value "$value")
|
||||||
|
sed -i "s|\"${key}\":\"[^\"]*\"|\"${key}\":\"${escaped_value}\"|g" $TEMP_FILE
|
||||||
|
echo "Configuration depuis .env : ${key}=${value}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < "$ENV_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parcours des variables d'environnement (priorité sur .env)
|
||||||
|
echo "Vérification des variables d'environnement"
|
||||||
|
env | grep '^NEXT_PUBLIC_' | while read -r line; do
|
||||||
|
var_name=$(echo "$line" | cut -d= -f1)
|
||||||
|
var_value=$(echo "$line" | cut -d= -f2-)
|
||||||
|
|
||||||
|
escaped_value=$(escape_value "$var_value")
|
||||||
|
sed -i "s|\"${var_name}\":\"[^\"]*\"|\"${var_name}\":\"${escaped_value}\"|g" $TEMP_FILE
|
||||||
|
echo "Override depuis ENV : ${var_name}=${var_value}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Mise à jour du fichier de configuration
|
||||||
|
mv $TEMP_FILE $CONFIG_FILE
|
||||||
|
echo "Configuration mise à jour avec succès"
|
||||||
|
|
||||||
|
# Démarrage du serveur
|
||||||
|
echo "Démarrage du serveur Next.js"
|
||||||
|
exec node server.js
|
||||||
@ -1,5 +1,3 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
image: 'redis:latest'
|
image: 'redis:latest'
|
||||||
@ -13,32 +11,36 @@ services:
|
|||||||
expose:
|
expose:
|
||||||
- 5432
|
- 5432
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${DB_USER}
|
POSTGRES_USER: postgres
|
||||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_DB: school
|
POSTGRES_DB: school
|
||||||
TZ: Europe/Paris
|
TZ: Europe/Paris
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build:
|
image: git.v0id.ovh/n3wt-innov/n3wt-school/backend:latest
|
||||||
context: ./Back-End
|
ports:
|
||||||
target: production
|
- 8080:8080
|
||||||
expose:
|
|
||||||
- 8080
|
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Paris
|
- TZ=Europe/Paris
|
||||||
- TEST_MODE=False
|
- TEST_MODE=True
|
||||||
|
links:
|
||||||
|
- "database:database"
|
||||||
|
- "redis:redis"
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- database
|
- database
|
||||||
|
volumes:
|
||||||
|
- ./conf/application.json:/Back-End/Subscriptions/Configuration/application.json
|
||||||
|
command: python start.py
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
image: git.v0id.ovh/n3wt-innov/n3wt-school/frontend:latest
|
||||||
context: ./Front-End
|
|
||||||
target: production
|
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Paris
|
- TZ=Europe/Paris
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
|
volumes:
|
||||||
|
- ./conf/env:/app/.env
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
Reference in New Issue
Block a user