Refactor: remove setup wizard and related middleware, update settings management
This commit is contained in:
@@ -7,6 +7,7 @@ APP_URL=http://localhost:8080
|
|||||||
|
|
||||||
APP_PORT=8080
|
APP_PORT=8080
|
||||||
SEED_DEV_DATA=false
|
SEED_DEV_DATA=false
|
||||||
|
RUN_DB_SEED_ON_FIRST_START=true
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=mariadb
|
DB_HOST=mariadb
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -94,27 +94,17 @@ chmod -R 775 storage bootstrap/cache
|
|||||||
|
|
||||||
# 4. Avvia i container (build al primo avvio)
|
# 4. Avvia i container (build al primo avvio)
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
|
|
||||||
# 5. Installa le dipendenze PHP
|
|
||||||
docker compose exec app composer install
|
|
||||||
|
|
||||||
# 6. Installa le dipendenze Node.js
|
|
||||||
docker compose exec app npm install
|
|
||||||
|
|
||||||
# 7. Pubblica gli asset dei pacchetti Spatie
|
|
||||||
docker compose exec app php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
|
|
||||||
docker compose exec app php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
|
|
||||||
|
|
||||||
# 8. Esegui le migrazioni e i seeder
|
|
||||||
docker compose exec app php artisan migrate --seed
|
|
||||||
|
|
||||||
# 9. Crea il symbolic link per lo storage pubblico
|
|
||||||
docker compose exec app php artisan storage:link
|
|
||||||
|
|
||||||
# 10. Compila gli asset frontend
|
|
||||||
docker compose exec app npm run build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Il codice applicativo e montato direttamente dal filesystem host, quindi ogni modifica locale e immediatamente visibile nel container (senza rebuild ad ogni edit).
|
||||||
|
|
||||||
|
Al primo avvio del container `app` vengono eseguiti automaticamente:
|
||||||
|
|
||||||
|
- setup `.env` e `APP_KEY`
|
||||||
|
- install/build dipendenze
|
||||||
|
- `php artisan migrate --force`
|
||||||
|
- `php artisan db:seed --force` **solo al primo avvio** (marker persistente)
|
||||||
|
|
||||||
> **Nota**: La `APP_KEY` viene generata automaticamente al primo avvio se assente nel `.env`.
|
> **Nota**: La `APP_KEY` viene generata automaticamente al primo avvio se assente nel `.env`.
|
||||||
|
|
||||||
Al termine l'applicazione sarà disponibile su: **http://localhost:8080**
|
Al termine l'applicazione sarà disponibile su: **http://localhost:8080**
|
||||||
@@ -140,6 +130,7 @@ docker compose up -d --build
|
|||||||
| `APP_KEY` | (generata) | Chiave AES-256 per cifratura. **Mai condividere** |
|
| `APP_KEY` | (generata) | Chiave AES-256 per cifratura. **Mai condividere** |
|
||||||
| `APP_PORT` | `8080` | Porta host per l'applicazione |
|
| `APP_PORT` | `8080` | Porta host per l'applicazione |
|
||||||
| `SEED_DEV_DATA` | `false` | Se `true`, `php artisan db:seed` include anche i dati demo |
|
| `SEED_DEV_DATA` | `false` | Se `true`, `php artisan db:seed` include anche i dati demo |
|
||||||
|
| `RUN_DB_SEED_ON_FIRST_START` | `true` | Se `true`, esegue il seed automatico solo al primo avvio container |
|
||||||
| `DB_DATABASE` | `termanager2` | Nome database MariaDB |
|
| `DB_DATABASE` | `termanager2` | Nome database MariaDB |
|
||||||
| `DB_USERNAME` | `termanager2` | Utente database |
|
| `DB_USERNAME` | `termanager2` | Utente database |
|
||||||
| `DB_PASSWORD` | `secret` | Password database |
|
| `DB_PASSWORD` | `secret` | Password database |
|
||||||
|
|||||||
@@ -168,9 +168,8 @@ class Territorio extends Model
|
|||||||
$soglia = Setting::getValue('giorni_per_smarrito', 120);
|
$soglia = Setting::getValue('giorni_per_smarrito', 120);
|
||||||
|
|
||||||
return $query->attivi()
|
return $query->attivi()
|
||||||
->whereHas('assegnazioni', function ($q) use ($soglia) {
|
->whereHas('assegnazioneCorrente', function ($q) use ($soglia) {
|
||||||
$q->whereNull('returned_at')
|
$q->where('assigned_at', '<=', now()->subDays($soglia));
|
||||||
->where('assigned_at', '<=', now()->subDays($soglia));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
working_dir: /var/www/html
|
working_dir: /var/www/html
|
||||||
volumes:
|
volumes:
|
||||||
- app_code:/var/www/html
|
- ./:/var/www/html
|
||||||
- storage_data:/var/www/html/storage/app
|
|
||||||
networks:
|
networks:
|
||||||
- termanager2
|
- termanager2
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -24,6 +23,8 @@ services:
|
|||||||
start_period: 45s
|
start_period: 45s
|
||||||
environment:
|
environment:
|
||||||
- PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
|
- PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
|
||||||
|
- SEED_DEV_DATA=${SEED_DEV_DATA:-false}
|
||||||
|
- RUN_DB_SEED_ON_FIRST_START=${RUN_DB_SEED_ON_FIRST_START:-true}
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
build:
|
build:
|
||||||
@@ -34,7 +35,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "${APP_PORT:-8080}:80"
|
- "${APP_PORT:-8080}:80"
|
||||||
volumes:
|
volumes:
|
||||||
- app_code:/var/www/html:ro
|
- ./:/var/www/html:ro
|
||||||
networks:
|
networks:
|
||||||
- termanager2
|
- termanager2
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -90,14 +91,10 @@ services:
|
|||||||
- termanager2
|
- termanager2
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
app_code:
|
|
||||||
driver: local
|
|
||||||
db_data:
|
db_data:
|
||||||
driver: local
|
driver: local
|
||||||
redis_data:
|
redis_data:
|
||||||
driver: local
|
driver: local
|
||||||
storage_data:
|
|
||||||
driver: local
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
termanager2:
|
termanager2:
|
||||||
|
|||||||
@@ -37,37 +37,10 @@ upsert_env() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_app_code() {
|
|
||||||
local env_backup="/tmp/termanager2.env.backup"
|
|
||||||
|
|
||||||
rm -f "$env_backup"
|
|
||||||
|
|
||||||
if [ -f /var/www/html/.env ]; then
|
|
||||||
cp /var/www/html/.env "$env_backup"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp -a /app-src/. /var/www/html/
|
|
||||||
|
|
||||||
if [ -f "$env_backup" ]; then
|
|
||||||
mv "$env_backup" /var/www/html/.env
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
# 0. Sync application code from image to volume
|
# 0. Application code is bind-mounted from host
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
IMAGE_BUILD_FILE="/app-src/.image-build-id"
|
echo "[✓] Using bind-mounted application code from host."
|
||||||
VOLUME_BUILD_FILE="/var/www/html/.image-build-id"
|
|
||||||
|
|
||||||
if [ ! -f /var/www/html/artisan ]; then
|
|
||||||
echo "[*] Syncing application code to volume..."
|
|
||||||
sync_app_code
|
|
||||||
elif [ -f "$IMAGE_BUILD_FILE" ] && { [ ! -f "$VOLUME_BUILD_FILE" ] || ! cmp -s "$IMAGE_BUILD_FILE" "$VOLUME_BUILD_FILE"; }; then
|
|
||||||
echo "[*] New image detected. Syncing updated application code to volume..."
|
|
||||||
sync_app_code
|
|
||||||
else
|
|
||||||
echo "[✓] Application code already in volume."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
# 0b. Create required directories & fix permissions
|
# 0b. Create required directories & fix permissions
|
||||||
@@ -184,6 +157,25 @@ fi
|
|||||||
echo "[*] Running database migrations..."
|
echo "[*] Running database migrations..."
|
||||||
retry 10 3 php artisan migrate --force
|
retry 10 3 php artisan migrate --force
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 7b. Seed database on first container startup only
|
||||||
|
# -----------------------------------------------
|
||||||
|
SEED_MARKER_FILE="/var/www/html/storage/app/.db_seeded"
|
||||||
|
RUN_DB_SEED_ON_FIRST_START="${RUN_DB_SEED_ON_FIRST_START:-true}"
|
||||||
|
|
||||||
|
if [ "$RUN_DB_SEED_ON_FIRST_START" = "true" ]; then
|
||||||
|
if [ ! -f "$SEED_MARKER_FILE" ]; then
|
||||||
|
echo "[*] First startup detected. Running database seed..."
|
||||||
|
retry 5 3 php artisan db:seed --force
|
||||||
|
touch "$SEED_MARKER_FILE"
|
||||||
|
echo "[✓] Database seed completed and startup marker saved."
|
||||||
|
else
|
||||||
|
echo "[✓] Seed already executed on a previous startup."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[i] RUN_DB_SEED_ON_FIRST_START=false, skipping automatic seed."
|
||||||
|
fi
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
# 8. Cache config/routes/views
|
# 8. Cache config/routes/views
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|||||||
@@ -113,16 +113,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul class="divide-y divide-gray-100">
|
<ul class="divide-y divide-gray-100">
|
||||||
@forelse($daRientrare as $t)
|
@forelse($daRientrare as $t)
|
||||||
|
@php($assegnazioneCorrente = $t->assegnazioneCorrente)
|
||||||
<li class="px-4 py-2.5 flex items-center justify-between hover:bg-gray-50">
|
<li class="px-4 py-2.5 flex items-center justify-between hover:bg-gray-50">
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ route('territori.show', $t) }}" class="text-sm font-semibold text-gray-900 hover:text-indigo-600">N° {{ $t->numero }}</a>
|
<a href="{{ route('territori.show', $t) }}" class="text-sm font-semibold text-gray-900 hover:text-indigo-600">N° {{ $t->numero }}</a>
|
||||||
<p class="text-xs text-gray-500">
|
<p class="text-xs text-gray-500">
|
||||||
{{ $t->assegnazioneCorrente?->proclamatore?->nome_completo }}
|
{{ $assegnazioneCorrente?->proclamatore?->nome_completo }}
|
||||||
— {{ $t->assegnazioneCorrente?->giorni }} giorni
|
— {{ $assegnazioneCorrente?->giorni }} giorni
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@can('territori.return')
|
@can('territori.return')
|
||||||
<a href="{{ route('assegnazioni.rientra', $t->assegnazioneCorrente) }}" class="text-xs font-medium text-red-600 hover:text-red-800">Rientra →</a>
|
@if($assegnazioneCorrente)
|
||||||
|
<a href="{{ route('assegnazioni.rientra', ['assegnazione' => $assegnazioneCorrente->id]) }}" class="text-xs font-medium text-red-600 hover:text-red-800">Rientra →</a>
|
||||||
|
@endif
|
||||||
@endcan
|
@endcan
|
||||||
</li>
|
</li>
|
||||||
@empty
|
@empty
|
||||||
|
|||||||
1
storage/app/.app_key
Normal file
1
storage/app/.app_key
Normal file
@@ -0,0 +1 @@
|
|||||||
|
base64:7ycOQwH6FjKdElpvJW9JU33pxtNAbOHxGhj6s930X+U=
|
||||||
0
storage/app/.db_seeded
Normal file
0
storage/app/.db_seeded
Normal file
Reference in New Issue
Block a user