feat: Version 3.5.2 - Configuration Stripe et gestion des immeubles
- Configuration complète Stripe pour les 3 environnements (DEV/REC/PROD) * DEV: Clés TEST Pierre (mode test) * REC: Clés TEST Client (mode test) * PROD: Clés LIVE Client (mode live) - Ajout de la gestion des bases de données immeubles/bâtiments * Configuration buildings_database pour DEV/REC/PROD * Service BuildingService pour enrichissement des adresses - Optimisations pages et améliorations ergonomie - Mises à jour des dépendances Composer - Nettoyage des fichiers obsolètes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -75,8 +75,8 @@ cleanup_old_backups() {
|
||||
"pra") prefix="api-pra-" ;;
|
||||
esac
|
||||
|
||||
echo_info "Cleaning old backups (keeping last 10)..."
|
||||
ls -t "${BACKUP_DIR}"/${prefix}*.tar.gz 2>/dev/null | tail -n +11 | xargs -r rm -f && {
|
||||
echo_info "Cleaning old backups (keeping last 5)..."
|
||||
ls -t "${BACKUP_DIR}"/${prefix}*.tar.gz 2>/dev/null | tail -n +6 | xargs -r rm -f && {
|
||||
REMAINING_BACKUPS=$(ls "${BACKUP_DIR}"/${prefix}*.tar.gz 2>/dev/null | wc -l)
|
||||
echo_info "Kept ${REMAINING_BACKUPS} backup(s) for ${TARGET_ENV}"
|
||||
}
|
||||
@@ -164,9 +164,12 @@ if [ "$SOURCE_TYPE" = "local_code" ]; then
|
||||
--exclude='.gitignore' \
|
||||
--exclude='.vscode' \
|
||||
--exclude='logs' \
|
||||
--exclude='sessions' \
|
||||
--exclude='opendata' \
|
||||
--exclude='*.template' \
|
||||
--exclude='*.sh' \
|
||||
--exclude='.env' \
|
||||
--exclude='.env_marker' \
|
||||
--exclude='*.log' \
|
||||
--exclude='.DS_Store' \
|
||||
--exclude='README.md' \
|
||||
@@ -193,6 +196,8 @@ elif [ "$SOURCE_TYPE" = "remote_container" ]; then
|
||||
incus exec ${SOURCE_CONTAINER} -- tar \
|
||||
--exclude='logs' \
|
||||
--exclude='uploads' \
|
||||
--exclude='sessions' \
|
||||
--exclude='opendata' \
|
||||
-czf /tmp/${ARCHIVE_NAME} -C ${API_PATH} .
|
||||
" || echo_error "Failed to create archive on remote"
|
||||
|
||||
@@ -254,18 +259,29 @@ if [ "$DEST_HOST" != "local" ]; then
|
||||
|
||||
# Déployer sur le container de destination
|
||||
echo_info "Extracting on destination container..."
|
||||
|
||||
# Déterminer le nom de l'environnement pour le marqueur
|
||||
case $TARGET_ENV in
|
||||
"dev") ENV_MARKER="development" ;;
|
||||
"rca") ENV_MARKER="recette" ;;
|
||||
"pra") ENV_MARKER="production" ;;
|
||||
esac
|
||||
|
||||
ssh -i ${HOST_KEY} -p ${HOST_PORT} ${HOST_USER}@${DEST_HOST} "
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
# Pousser l'archive dans le container
|
||||
incus project switch ${INCUS_PROJECT} &&
|
||||
incus file push /tmp/${ARCHIVE_NAME} ${DEST_CONTAINER}/tmp/${ARCHIVE_NAME} &&
|
||||
|
||||
# Nettoyer sélectivement (préserver logs et uploads)
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH} -mindepth 1 -maxdepth 1 ! -name 'uploads' ! -name 'logs' -exec rm -rf {} \; 2>/dev/null || true &&
|
||||
|
||||
|
||||
# Nettoyer sélectivement (préserver logs, uploads et sessions)
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH} -mindepth 1 -maxdepth 1 ! -name 'uploads' ! -name 'logs' ! -name 'sessions' -exec rm -rf {} \; 2>/dev/null || true &&
|
||||
|
||||
# Extraire l'archive
|
||||
incus exec ${DEST_CONTAINER} -- tar -xzf /tmp/${ARCHIVE_NAME} -C ${API_PATH}/ &&
|
||||
|
||||
# Créer le marqueur d'environnement pour la détection CLI
|
||||
incus exec ${DEST_CONTAINER} -- bash -c 'echo \"${ENV_MARKER}\" > ${API_PATH}/.env_marker' &&
|
||||
|
||||
# Permissions
|
||||
incus exec ${DEST_CONTAINER} -- chown -R ${FINAL_OWNER}:${FINAL_GROUP} ${API_PATH} &&
|
||||
@@ -273,24 +289,74 @@ if [ "$DEST_HOST" != "local" ]; then
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH} -type f -exec chmod 644 {} \; &&
|
||||
|
||||
# Permissions spéciales pour logs
|
||||
incus exec ${DEST_CONTAINER} -- test -d ${API_PATH}/logs &&
|
||||
incus exec ${DEST_CONTAINER} -- chown -R ${FINAL_OWNER_LOGS}:${FINAL_GROUP_LOGS} ${API_PATH}/logs &&
|
||||
incus exec ${DEST_CONTAINER} -- chmod -R 755 ${API_PATH}/logs || true &&
|
||||
incus exec ${DEST_CONTAINER} -- mkdir -p ${API_PATH}/logs/events &&
|
||||
incus exec ${DEST_CONTAINER} -- chown -R ${FINAL_OWNER_LOGS}:${FINAL_GROUP} ${API_PATH}/logs &&
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH}/logs -type d -exec chmod 750 {} \; &&
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH}/logs -type f -exec chmod 640 {} \; &&
|
||||
|
||||
# Permissions spéciales pour uploads
|
||||
incus exec ${DEST_CONTAINER} -- test -d ${API_PATH}/uploads &&
|
||||
incus exec ${DEST_CONTAINER} -- chown -R ${FINAL_OWNER_LOGS}:${FINAL_GROUP_LOGS} ${API_PATH}/uploads &&
|
||||
incus exec ${DEST_CONTAINER} -- chmod -R 755 ${API_PATH}/uploads || true &&
|
||||
|
||||
# Composer
|
||||
incus exec ${DEST_CONTAINER} -- bash -c 'cd ${API_PATH} && composer install --no-dev --optimize-autoloader' || echo 'Composer install skipped' &&
|
||||
incus exec ${DEST_CONTAINER} -- mkdir -p ${API_PATH}/uploads &&
|
||||
incus exec ${DEST_CONTAINER} -- chown -R ${FINAL_OWNER_LOGS}:${FINAL_GROUP} ${API_PATH}/uploads &&
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH}/uploads -type d -exec chmod 750 {} \; &&
|
||||
incus exec ${DEST_CONTAINER} -- find ${API_PATH}/uploads -type f -exec chmod 640 {} \; &&
|
||||
|
||||
# Permissions spéciales pour sessions
|
||||
incus exec ${DEST_CONTAINER} -- mkdir -p ${API_PATH}/sessions &&
|
||||
incus exec ${DEST_CONTAINER} -- chown -R ${FINAL_OWNER_LOGS}:${FINAL_GROUP} ${API_PATH}/sessions &&
|
||||
incus exec ${DEST_CONTAINER} -- chmod 700 ${API_PATH}/sessions &&
|
||||
|
||||
# Composer (installation stricte - échec bloquant)
|
||||
incus exec ${DEST_CONTAINER} -- bash -c 'cd ${API_PATH} && composer install --no-dev --optimize-autoloader' || { echo 'ERROR: Composer install failed'; exit 1; } &&
|
||||
|
||||
# Nettoyage
|
||||
incus exec ${DEST_CONTAINER} -- rm -f /tmp/${ARCHIVE_NAME} &&
|
||||
rm -f /tmp/${ARCHIVE_NAME}
|
||||
" || echo_error "Deployment failed on destination"
|
||||
|
||||
|
||||
echo_info "Remote backup saved: ${REMOTE_BACKUP_DIR} on ${DEST_CONTAINER}"
|
||||
|
||||
# Nettoyage des anciens backups sur le container distant
|
||||
echo_info "Cleaning old backup directories on ${DEST_CONTAINER}..."
|
||||
ssh -i ${HOST_KEY} -p ${HOST_PORT} ${HOST_USER}@${DEST_HOST} "
|
||||
incus exec ${DEST_CONTAINER} -- bash -c 'rm -rf ${API_PATH}_backup_*'
|
||||
" && echo_info "Old backups cleaned" || echo_warning "Could not clean old backups"
|
||||
|
||||
# =====================================
|
||||
# Configuration des tâches CRON
|
||||
# =====================================
|
||||
|
||||
echo_step "Configuring CRON tasks..."
|
||||
|
||||
ssh -i ${HOST_KEY} -p ${HOST_PORT} ${HOST_USER}@${DEST_HOST} "
|
||||
incus exec ${DEST_CONTAINER} -- bash <<'EOFCRON'
|
||||
# Sauvegarder les crons existants (hors geosector)
|
||||
crontab -l 2>/dev/null | grep -v 'geosector/api/scripts/cron' > /tmp/crontab_backup || true
|
||||
|
||||
# Créer le nouveau crontab avec les tâches CRON pour l'API
|
||||
cat /tmp/crontab_backup > /tmp/new_crontab
|
||||
cat >> /tmp/new_crontab <<'EOF'
|
||||
|
||||
# GEOSECTOR API - Email queue processing (every 5 minutes)
|
||||
*/5 * * * * /usr/bin/php /var/www/geosector/api/scripts/cron/process_email_queue.php >> /var/www/geosector/api/logs/email_queue.log 2>&1
|
||||
|
||||
# GEOSECTOR API - Security data cleanup (daily at 2am)
|
||||
0 2 * * * /usr/bin/php /var/www/geosector/api/scripts/cron/cleanup_security_data.php >> /var/www/geosector/api/logs/cleanup_security.log 2>&1
|
||||
|
||||
# GEOSECTOR API - Stripe devices update (weekly Sunday at 3am)
|
||||
0 3 * * 0 /usr/bin/php /var/www/geosector/api/scripts/cron/update_stripe_devices.php >> /var/www/geosector/api/logs/stripe_devices.log 2>&1
|
||||
EOF
|
||||
|
||||
# Installer le nouveau crontab
|
||||
crontab /tmp/new_crontab
|
||||
|
||||
# Nettoyer
|
||||
rm -f /tmp/crontab_backup /tmp/new_crontab
|
||||
|
||||
# Afficher les crons installés
|
||||
echo 'CRON tasks installed:'
|
||||
crontab -l | grep geosector
|
||||
EOFCRON
|
||||
" && echo_info "CRON tasks configured successfully" || echo_warning "CRON configuration failed"
|
||||
fi
|
||||
|
||||
# L'archive reste dans le dossier de backup, pas de nettoyage nécessaire
|
||||
|
||||
Reference in New Issue
Block a user