fonctionnement environnement dev, script de restart container pour appliquer les chgts, mode watch frankenphp semble hs
Some checks failed
Cadoles/hydra-sql/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
2025-10-01 15:33:58 +02:00
parent 97289f96fd
commit d15579578e
5 changed files with 72 additions and 3 deletions

2
.env
View File

@@ -17,7 +17,7 @@
APP_ENV=prod APP_ENV=prod
APP_SECRET=406ccaa0c76a451fdcc2307ea146cbef APP_SECRET=406ccaa0c76a451fdcc2307ea146cbef
URL_LINK="http://localhost" URL_LINK="http://localhost"
VERSION=dev VERSION=sql-dev
ENABLED_LOCALES='{["en","fr"]}' ENABLED_LOCALES='{["en","fr"]}'
# configuration bdd # configuration bdd

View File

@@ -20,6 +20,8 @@ framework:
cookie_samesite: lax cookie_samesite: lax
storage_factory_id: session.storage.factory.native storage_factory_id: session.storage.factory.native
cookie_path: "%cookie_path%" cookie_path: "%cookie_path%"
name: HYDRA_SQL_SESSID
assets: assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
router: router:

View File

@@ -58,7 +58,7 @@
path_regexp skipPaths ^/({$CADDY_LOG_FILTER:health|metrics})$ path_regexp skipPaths ^/({$CADDY_LOG_FILTER:health|metrics})$
} }
log_skip @shouldSkip log_skip @shouldSkip
log { log {
output stdout output stdout
format {$CADDY_LOG_FORMAT:console} format {$CADDY_LOG_FORMAT:console}

View File

@@ -117,3 +117,31 @@ copier les images et les fonts dans les dossier ./assets
modifier si besoin le fichier theme-entrypoints.js modifier si besoin le fichier theme-entrypoints.js
lancer un `npm run build` lancer un `npm run build`
### watch-dev-optimized.sh
L'option watch du worker frankenphp ne semble pas bien fonctionner pour le moment
Script Bash pour le développement Symfony/FrankenPHP dans Docker:
il surveille les changements sur des dossiers spécifiés (/src, /templates, etc) et redémarre automatiquement le container correspondant pour refléter les changements en temps réel.
Il ignore les dossiers var/cache et vendor pour éviter les redémarrages inutiles.
#### context
Si le mode watch de compose est activé, ne pas oublier de enable watch dans la console
#### Pre requis
* Docker
* Docker compose
* inotify-tools (`sudo pacman -S inotify-tools`)
#### Utilisation
./watch-dev.sh [nom_du_container]
le nom peut être partiel, par exemple `sql`
ou complet, par exemple `hydra-dev-hydra-sql-1`
Chaque projet doit contenir son propre script de surveillance/redémarrage

39
watch-dev-optimized.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Nom du container en argument, valeur par défaut "hydra-sql"
CONTAINER_KEY="${1:-hydra-sql}"
# Chercher le nom exact du container correspondant
CONTAINER=$(docker ps --filter "name=${CONTAINER_KEY}" --format "{{.Names}}" | head -n1)
if [[ -n "$CONTAINER" ]]; then
echo "Container trouvé : $CONTAINER"
else
echo "Aucun container exact trouvé pour '$CONTAINER_KEY'. Liste des containers contenant ce mot-clé :"
docker ps --format "{{.Names}}" | grep "$CONTAINER_KEY" || echo "Aucun container trouvé"
exit 1
fi
WATCH_DIRS=("src" "templates" "config")
DEBOUNCE_TIME=0.5
# vérifier que inotifywait est installé
if ! command -v inotifywait &> /dev/null; then
echo "inotifywait manquant, installez via 'sudo apt install inotify-tools'"
exit 1
fi
echo "Watching directories: ${WATCH_DIRS[*]} for container: $CONTAINER"
echo "Ignoring var/cache and vendor"
while true; do
CHANGES=$(inotifywait -r -e modify,create,delete --format '%w%f' \
--exclude 'var/cache|vendor' "${WATCH_DIRS[@]}")
if [[ -n "$CHANGES" ]]; then
echo "$(date '+%H:%M:%S') - change detected, debouncing for $DEBOUNCE_TIME s..."
sleep $DEBOUNCE_TIME
echo "$(date '+%H:%M:%S') - restarting container $CONTAINER"
docker restart "$CONTAINER"
fi
done