Docker image for building ReactNative APKs. Latest Java + Node.js + Android SDK.
github.com/adambene/react-native-android
hub.docker.com/r/adambene/react-native-android
### Command Line Build a React Native project for Android from the command line.
cd my-project/
docker run -t -i \
-v $(pwd):/workspace \
-v ~/.gradle/:/home/user/.gradle/ \
-w /workspace \
-e LOCAL_USER_ID=`id -u $USER` \
adambene/react-native-android \
/bin/sh -c "cd android && ./gradlew --stacktrace assembleRelease"
Build a React Native project for Android with npm
.
"scripts": {
"build-with-docker-debug": "docker run -t -i -v $(pwd):/workspace -v ~/.gradle/:/home/user/.gradle/ -w /workspace -e LOCAL_USER_ID=`id -u $USER` adambene/react-native-android /bin/sh -c \"cd android && ./gradlew --stacktrace assembleDebug\"",
"build-with-docker-release": "docker run -t -i -v $(pwd):/workspace -v ~/.gradle/:/home/user/.gradle/ -w /workspace -e LOCAL_USER_ID=`id -u $USER` adambene/react-native-android /bin/sh -c \"cd android && ./gradlew --stacktrace assembleRelease\""
},
npm run build-with-docker-debug
npm run build-with-docker-release
The container runs the command with username user
and user id LOCAL_USER_ID
. This is important to avoid permission problems. The built files are owned by user
not the root.
### Volumes
Projects directory as workspace and host's ~/.gradle/
directory is needed.
Debug and release APK are built into the usual build directory android/app/build/outputs/apk/
.
You can override the following defaults either in your Dockerfile or command line using -e
.
ENV ANDROID_COMPONENTS platform-tools,build-tools-23.0.1,build-tools-23.0.3,android-23
ENV GOOGLE_COMPONENTS extra-android-m2repository,extra-google-m2repository,extra-google-google_play_services,extra-google-gcm