2026-05-16 18:25:48 +02:00
|
|
|
# Docker — BitePlan
|
2026-03-25 10:24:19 +01:00
|
|
|
|
2026-07-12 19:30:34 +02:00
|
|
|
Un solo container, usato per test riproducibili e build APK headless.
|
|
|
|
|
Lo sviluppo (hot reload) avviene sull'host con Flutter + emulatore Android — vedi `CLAUDE.md`.
|
2026-05-17 23:39:00 +02:00
|
|
|
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-07-12 19:30:34 +02:00
|
|
|
## Container build (`docker/`)
|
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-07-12 19:30:34 +02:00
|
|
|
bash docker/build.sh
|
2026-05-16 18:25:48 +02:00
|
|
|
# → 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-07-12 19:30:34 +02:00
|
|
|
bash docker/build.sh --release
|
2026-05-16 18:25:48 +02:00
|
|
|
# → 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
|
|
|
|
|
|
2026-07-12 19:30:34 +02:00
|
|
|
I test usano l'immagine `biteplan-build`, creata automaticamente al primo `bash docker/build.sh`.
|
2026-05-17 23:39:00 +02:00
|
|
|
|
|
|
|
|
```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-07-12 19:30:34 +02:00
|
|
|
# 1. Sviluppo (host, no Docker — vedi CLAUDE.md)
|
|
|
|
|
emulator -avd biteplan &
|
|
|
|
|
flutter run
|
2026-05-17 23:39:00 +02:00
|
|
|
|
|
|
|
|
# 2. Test
|
|
|
|
|
docker run --rm -v "$(pwd):/workspace" -w /workspace biteplan-build \
|
|
|
|
|
bash -c "flutter pub get && flutter test"
|
|
|
|
|
|
|
|
|
|
# 3. Build
|
2026-07-12 19:30:34 +02:00
|
|
|
bash docker/build.sh # → dist/biteplan-debug.apk
|
|
|
|
|
bash docker/build.sh --release # → dist/biteplan-release.apk
|
2026-05-17 23:39:00 +02:00
|
|
|
|
|
|
|
|
# 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-07-13 18:48:14 +02:00
|
|
|
- App ID: `com.davide.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`
|