2026-05-16 18:25:48 +02:00
|
|
|
# Docker — BitePlan
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
Due container distinti: uno per lo sviluppo con hot reload, uno per la build APK headless.
|
|
|
|
|
Tutti i comandi vanno eseguiti dalla **root del progetto** (`~/biteplan`), non da `docker/`.
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
---
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
## Container dev (`docker/dev/`)
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
Avvia un web server Flutter accessibile dal browser, con hot reload.
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
```bash
|
|
|
|
|
cd docker/dev
|
|
|
|
|
docker compose up
|
|
|
|
|
```
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
Apri **http://localhost:5173** nel browser.
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
### Hot reload
|
|
|
|
|
|
|
|
|
|
Con il container attivo, in un altro terminale:
|
2026-03-25 10:24:19 +01:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-16 18:25:48 +02:00
|
|
|
docker compose attach dev
|
2026-05-17 23:39:00 +02:00
|
|
|
# r → hot reload | R → hot restart | q → esci
|
2026-03-28 10:10:43 +01:00
|
|
|
```
|
|
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
Le modifiche ai file `.dart` sull'host sono visibili subito nel container grazie al volume
|
|
|
|
|
montato — basta premere `r` per ricaricare.
|
2026-05-16 18:25:48 +02:00
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
> Prima esecuzione: scarica l'immagine Flutter (~500 MB), richiede 5-10 minuti.
|
2026-05-16 18:25:48 +02:00
|
|
|
> Le successive usano la cache Docker e sono molto più rapide.
|
|
|
|
|
|
2026-03-28 10:10:43 +01:00
|
|
|
---
|
|
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
## Container build (`docker/build/`)
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
Build headless riproducibile per generare l'APK Android.
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
### Build debug
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
APK firmato con il debug keystore di Android — adatto per installazione diretta sul dispositivo.
|
2026-03-28 10:10:43 +01:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-16 18:25:48 +02:00
|
|
|
bash docker/build/build.sh
|
|
|
|
|
# → dist/biteplan-debug.apk
|
2026-03-28 10:10:43 +01:00
|
|
|
```
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
### Build release
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-18 22:13:54 +02:00
|
|
|
APK firmato con keystore — necessario per la distribuzione.
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-18 22:13:54 +02:00
|
|
|
**1. Ottieni il keystore**
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-18 22:13:54 +02:00
|
|
|
Il file `docker/biteplan.jks` non è nel repo (è in `.gitignore`).
|
|
|
|
|
Hai due opzioni:
|
|
|
|
|
|
|
|
|
|
- **Collaboratore**: ricevi `docker/biteplan.jks` dall'autore del progetto via canale sicuro
|
|
|
|
|
(es. password manager condiviso). Usare lo stesso keystore garantisce APK aggiornabili
|
|
|
|
|
sui dispositivi che hanno già l'app installata.
|
|
|
|
|
|
|
|
|
|
- **Fork/uso personale**: genera il tuo keystore (produce APK non compatibili con quelli
|
|
|
|
|
firmati dall'autore):
|
|
|
|
|
```bash
|
|
|
|
|
keytool -genkey -v \
|
|
|
|
|
-keystore docker/biteplan.jks \
|
|
|
|
|
-alias biteplan \
|
|
|
|
|
-keyalg RSA -keysize 2048 -validity 10000
|
|
|
|
|
```
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-18 22:13:54 +02:00
|
|
|
> Conserva `docker/biteplan.jks` in un posto sicuro: perderlo significa non poter più
|
|
|
|
|
> pubblicare aggiornamenti firmati con la stessa identità.
|
2026-05-16 18:25:48 +02:00
|
|
|
|
2026-05-18 22:04:00 +02:00
|
|
|
**2. Esporta la password del keystore**
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
export BITEPLAN_KEYSTORE_PASS=tuapassword
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
La variabile è richiesta ad ogni sessione di terminale. Per non doverla riscrivere ogni volta,
|
|
|
|
|
aggiungila a `~/.bashrc` o `~/.zshrc`.
|
|
|
|
|
|
|
|
|
|
**3. Esegui la build release**
|
2026-03-28 10:10:43 +01:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-16 18:25:48 +02:00
|
|
|
bash docker/build/build.sh --release
|
|
|
|
|
# → dist/biteplan-release.apk
|
2026-03-25 10:24:19 +01:00
|
|
|
```
|
|
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
Il keystore viene montato nel container come volume read-only e non viene mai copiato
|
|
|
|
|
nell'immagine Docker.
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-18 22:04:00 +02:00
|
|
|
> Se la build fallisce con `Output file '…/biteplan-aligned.apk' exists`, esegui
|
|
|
|
|
> `rm dist/biteplan-aligned.apk` e rilancia. Lo script rimuove il file automaticamente
|
|
|
|
|
> nelle versioni aggiornate, ma eventuali run interrotte possono lasciarlo indietro.
|
|
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
> Prima esecuzione: scarica Flutter SDK + Android SDK (~1-2 GB), richiede 10-15 minuti.
|
2026-03-28 10:10:43 +01:00
|
|
|
|
2026-05-17 23:39:00 +02:00
|
|
|
### Installazione sul dispositivo
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
adb install dist/biteplan-debug.apk
|
|
|
|
|
# oppure copia manualmente dist/biteplan-release.apk via USB o Drive
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Test
|
|
|
|
|
|
|
|
|
|
I test non richiedono il container dev — usano l'immagine `biteplan-build`, creata
|
|
|
|
|
automaticamente al primo `bash docker/build/build.sh`.
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Tutti i test (110 test — unit + widget)
|
|
|
|
|
docker run --rm -v "$(pwd):/workspace" -w /workspace biteplan-build \
|
|
|
|
|
bash -c "flutter pub get && flutter test"
|
|
|
|
|
|
|
|
|
|
# Un singolo file
|
|
|
|
|
docker run --rm -v "$(pwd):/workspace" -w /workspace biteplan-build \
|
|
|
|
|
bash -c "flutter test test/features/meal_planner/qr_test.dart"
|
|
|
|
|
|
|
|
|
|
# Una singola feature
|
|
|
|
|
docker run --rm -v "$(pwd):/workspace" -w /workspace biteplan-build \
|
|
|
|
|
bash -c "flutter test test/features/shopping_list/"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Prima configurazione (android/ assente)
|
|
|
|
|
|
|
|
|
|
Se la cartella `android/` non esiste ancora, lo script `build.sh` la genera
|
|
|
|
|
automaticamente tramite `flutter create` all'interno del container — non è necessario
|
|
|
|
|
avere Flutter installato sull'host.
|
|
|
|
|
|
2026-03-28 10:10:43 +01:00
|
|
|
---
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
## Flusso completo
|
2026-03-25 10:24:19 +01:00
|
|
|
|
|
|
|
|
```
|
2026-05-17 23:39:00 +02:00
|
|
|
# 1. Sviluppo
|
2026-05-16 18:25:48 +02:00
|
|
|
cd docker/dev && docker compose up
|
2026-05-17 23:39:00 +02:00
|
|
|
→ http://localhost:5173 (hot reload con 'r')
|
|
|
|
|
|
|
|
|
|
# 2. Test
|
|
|
|
|
docker run --rm -v "$(pwd):/workspace" -w /workspace biteplan-build \
|
|
|
|
|
bash -c "flutter pub get && flutter test"
|
|
|
|
|
|
|
|
|
|
# 3. Build
|
|
|
|
|
bash docker/build/build.sh # → dist/biteplan-debug.apk
|
|
|
|
|
bash docker/build/build.sh --release # → dist/biteplan-release.apk
|
|
|
|
|
|
|
|
|
|
# 4. Installazione
|
2026-05-16 18:25:48 +02:00
|
|
|
adb install dist/biteplan-debug.apk
|
2026-03-25 10:24:19 +01:00
|
|
|
```
|
|
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
---
|
|
|
|
|
|
2026-03-25 10:24:19 +01:00
|
|
|
## Note
|
|
|
|
|
|
2026-05-16 18:25:48 +02:00
|
|
|
- App ID: `com.biteplan.biteplan`
|
2026-03-25 10:24:19 +01:00
|
|
|
- Android target: API 34
|
2026-05-16 18:25:48 +02:00
|
|
|
- Il keystore non viene mai copiato nell'immagine Docker (volume read-only)
|
2026-05-17 23:39:00 +02:00
|
|
|
- `dist/` è in `.gitignore`
|