diff --git a/README.md b/README.md index d212015..0217d86 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,36 @@ Note: The API credentials are required for: - Nutritional information retrieval - Food database integration +## Building Android APK with Docker + +### Prerequisites + +- Docker with at least 8GB RAM allocated, gradle build fails with OOM otherwise + +### Build Instructions + +```bash +cd mobile/nutrihub + +# Build the Docker image +docker build -t nutrihub-apk . + +# Create a temporary container +docker create --name nutrihub-temp nutrihub-apk + +# Extract the APK +docker cp nutrihub-temp:/app/android/app/build/outputs/apk/release/app-release.apk ./nutrihub.apk + +# Clean up +docker rm nutrihub-temp +``` + +### Troubleshooting + +**If build fails with "Gradle daemon disappeared":** +- Increase Docker memory to 8GB+ in Docker settings +- Restart Docker + ## Manual Setup ### Backend Setup diff --git a/mobile/nutrihub/Dockerfile b/mobile/nutrihub/Dockerfile new file mode 100644 index 0000000..5360815 --- /dev/null +++ b/mobile/nutrihub/Dockerfile @@ -0,0 +1,28 @@ +FROM --platform=linux/amd64 mobiledevops/android-sdk-image:latest + +# Install Node.js +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ + apt-get install -y nodejs && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +COPY . . +RUN npm install + + +# Generate native Android code +RUN npx expo prebuild --platform android --clean + +# Configure Gradle memory settings +WORKDIR /app/android +RUN echo "org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError" >> gradle.properties && \ + echo "org.gradle.daemon=false" >> gradle.properties && \ + echo "org.gradle.parallel=false" >> gradle.properties + +# Build the release APK +RUN ./gradlew assembleRelease --stacktrace + +# APK will be at: /app/android/app/build/outputs/apk/release/app-release.apk +CMD ["echo", "APK built successfully at /app/android/app/build/outputs/apk/release/app-release.apk"]