build: add mappings sync cron
This commit is contained in:
parent
e53b4ca85a
commit
5b86d89be2
4 changed files with 26 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ Exemple : un mapping `mcp/graylog/install.sh` peut servir le fichier `install.sh
|
|||
- `/` redirige vers l’URL configurée dans `/admin/settings`, ou vers `/admin` si aucune URL n’est configurée.
|
||||
- Un mapping lie un chemin public `.sh` à une URL Git, une référence Git et un chemin de fichier dans le dépôt.
|
||||
- Le bouton `Synchroniser` clone ou met à jour le dépôt, extrait la référence demandée et copie le fichier dans le cache.
|
||||
- En production, un cron embarqué dans l’image relance `app:mappings:sync` toutes les 5 minutes.
|
||||
- Les chemins publics hors `/admin` servent uniquement les scripts déjà synchronisés.
|
||||
- Un token d’accès optionnel peut être renseigné pour les dépôts privés en HTTPS. Il est utilisé via `GIT_ASKPASS` pendant la synchronisation.
|
||||
|
||||
|
|
@ -40,6 +41,8 @@ Les migrations SQLite sont exécutées au démarrage du conteneur `app`. Les vol
|
|||
- `app-data` : base SQLite `/app/var/data/app.db`
|
||||
- `app-cache` : dépôts clonés et scripts servis depuis `/app/var/bootstrap-cache`
|
||||
|
||||
Le fichier `crontab` à la racine du projet est copié dans l’image `app`. Le cron démarre uniquement quand `APP_ENV=prod` et que le conteneur lance `php-fpm`.
|
||||
|
||||
Créer ou mettre à jour un compte admin :
|
||||
|
||||
```bash
|
||||
|
|
|
|||
4
crontab
Normal file
4
crontab
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
*/5 * * * * . /app/var/cron-env && su -m www-data -s /bin/sh -c 'cd /app && php bin/console app:mappings:sync' >> /proc/1/fd/1 2>> /proc/1/fd/2
|
||||
|
|
@ -14,8 +14,10 @@ RUN composer install --no-dev --prefer-dist --no-interaction --no-progress --no-
|
|||
COPY . .
|
||||
COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini
|
||||
COPY docker/entrypoint.sh /usr/local/bin/app-entrypoint
|
||||
COPY crontab /etc/crontabs/root
|
||||
|
||||
RUN chmod +x /usr/local/bin/app-entrypoint \
|
||||
&& chmod 0600 /etc/crontabs/root \
|
||||
&& mkdir -p var/data var/bootstrap-cache \
|
||||
&& composer dump-autoload --classmap-authoritative --no-dev \
|
||||
&& composer run-script --no-dev post-install-cmd \
|
||||
|
|
|
|||
|
|
@ -5,7 +5,24 @@ mkdir -p /app/var/data /app/var/bootstrap-cache
|
|||
chown -R www-data:www-data /app/var
|
||||
|
||||
if [ "${APP_ENV:-prod}" != "test" ]; then
|
||||
php /app/bin/console cache:clear --no-warmup --no-interaction
|
||||
php /app/bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
|
||||
fi
|
||||
|
||||
if [ "${APP_ENV:-prod}" = "prod" ] && [ "${1:-}" = "php-fpm" ]; then
|
||||
php -r '
|
||||
$names = ["APP_ENV", "APP_DEBUG", "APP_SECRET", "DATABASE_URL", "APP_CACHE_DIR", "DEFAULT_URI"];
|
||||
foreach ($names as $name) {
|
||||
$value = getenv($name);
|
||||
if ($value !== false) {
|
||||
echo "export ".$name."=".escapeshellarg($value).PHP_EOL;
|
||||
}
|
||||
}
|
||||
' > /app/var/cron-env
|
||||
chown www-data:www-data /app/var/cron-env
|
||||
chmod 0600 /app/var/cron-env
|
||||
|
||||
crond -l 8 -L /proc/1/fd/1
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
|
|
|||
Loading…
Reference in a new issue