refactor: appiattisce docker/build/ in docker/

Con la rimozione di docker/dev/ non serve più distinguere due
container: Dockerfile e build.sh salgono di un livello, con i path
relativi (PROJECT_ROOT, keystore) aggiornati di conseguenza.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-12 19:29:40 +02:00
parent 9c4f460c9b
commit ed4422ef93
2 changed files with 114 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
RELEASE=false
for arg in "$@"; do
[[ "$arg" == "--release" ]] && RELEASE=true
done
echo "→ Build immagine biteplan-build..."
docker build -t biteplan-build "${SCRIPT_DIR}"
mkdir -p "${PROJECT_ROOT}/dist"
if [[ "$RELEASE" == "true" ]]; then
if [[ -z "${BITEPLAN_KEYSTORE_PASS}" ]]; then
echo "ERRORE: variabile BITEPLAN_KEYSTORE_PASS non impostata"
echo "Usa: export BITEPLAN_KEYSTORE_PASS=tuapassword"
exit 1
fi
KEYSTORE="${SCRIPT_DIR}/biteplan.jks"
if [[ ! -f "$KEYSTORE" ]]; then
echo "ERRORE: keystore non trovato in docker/biteplan.jks"
echo "Generalo con:"
echo " keytool -genkey -v -keystore docker/biteplan.jks -alias biteplan -keyalg RSA -keysize 2048 -validity 10000"
exit 1
fi
echo "→ Building release APK..."
docker run --rm \
-v "${PROJECT_ROOT}:/workspace" \
-v "gradle-cache:/root/.gradle" \
biteplan-build \
bash -c "cd /workspace && flutter pub get --enforce-lockfile && flutter pub run flutter_launcher_icons && flutter build apk --release"
echo "→ Zipalign..."
rm -f "${PROJECT_ROOT}/dist/biteplan-aligned.apk"
docker run --rm \
-v "${PROJECT_ROOT}:/workspace" \
biteplan-build \
bash -c "zipalign -v -p 4 \
/workspace/build/app/outputs/flutter-apk/app-release.apk \
/workspace/dist/biteplan-aligned.apk"
echo "→ Firma APK..."
docker run --rm \
-v "${PROJECT_ROOT}:/workspace" \
-v "$(realpath "${KEYSTORE%/*}"):/keystore:ro" \
-e BITEPLAN_KEYSTORE_PASS \
biteplan-build \
bash -c "apksigner sign \
--ks /keystore/biteplan.jks \
--ks-pass \"pass:\${BITEPLAN_KEYSTORE_PASS}\" \
--out /workspace/dist/biteplan-release.apk \
/workspace/dist/biteplan-aligned.apk && \
rm -f /workspace/dist/biteplan-aligned.apk && \
apksigner verify --verbose /workspace/dist/biteplan-release.apk"
echo ""
echo "✓ Release APK: dist/biteplan-release.apk"
else
echo "→ Building debug APK..."
docker run --rm \
-v "${PROJECT_ROOT}:/workspace" \
-v "gradle-cache:/root/.gradle" \
biteplan-build \
bash -c "cd /workspace && flutter pub get --enforce-lockfile && flutter pub run flutter_launcher_icons && flutter build apk --debug"
cp "${PROJECT_ROOT}/build/app/outputs/flutter-apk/app-debug.apk" \
"${PROJECT_ROOT}/dist/biteplan-debug.apk"
echo ""
echo "✓ Debug APK: dist/biteplan-debug.apk"
fi