Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions mobile/nutrihub/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]