Docker image for building TensorFlow Android demo app

docker pull danjarvis/tensorflow-android:1.0.0
docker ps
CONTAINER ID  IMAGE              COMMAND     CREATED                                  68f8994d3b19  <image>:<version>  "/bin/bash" 7 hours agoSTATUS      PORTS               NAMES
Up 7 hours 6006/tcp, 8888/tcp epic_minsky
docker commit 68f8994d3b19 danjarvis/tensorflow-android:1.0.0
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
danjarvis/tensorflow-android 1.0.0 4367bdf42c9c 36 mins ago 5.9 GB

Creating a Docker container for building the TensorFlow Android demo

docker run -it gcr.io/tensorflow/tensorflow:1.0.0-devel
Hello from TensorFlow. Everything seems to be working!
echo "set nocompatible" > ~/.exrc
apt-get update
apt-get install wget
mkdir /android
cd /android
wget https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
unzip tools_r25.2.3-linux.zip
rm tools_r25.2.3-linux.zip
wget https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip
unzip android-ndk-r12b-linux-x86_64.zip
rm android-ndk-r12b-linux-x86_64.zip
tools/bin/sdkmanager "platforms;android-23"
tools/bin/sdkmanager "build-tools;25.0.2"
docker commit 4367bdf42c9c danjarvis/tensorflow-android:1.0.0
cd /tensorflow
vi WORKSPACE
android_sdk_repository(
name = "androidsdk",
api_level = 23,
build_tools_version = "25.0.2",
path = "/android",
)
android_ndk_repository(
name="androidndk",
path="/android/android-ndk-r12b",
api_level=21)
docker commit 4367bdf42c9c danjarvis/tensorflow-android:1.0.0
cd /tensorflow
bazel build -c opt --local_resources 4096,4.0,1.0 -j 1 //tensorflow/examples/android:tensorflow_demo
Target //tensorflow/examples/android:tensorflow_demo up-to-date:
bazel-bin/tensorflow/examples/android/tensorflow_demo_deploy.jar
bazel-bin/tensorflow/examples/android/tensorflow_demo_unsigned.apk
bazel-bin/tensorflow/examples/android/tensorflow_demo.apk
INFO: Elapsed time: 1066.753s, Critical Path: 71.99s
bazel build --local_resources 4096,4.0,1.0 -j 1 tensorflow/python/tools:strip_unused
docker commit 4367bdf42c9c danjarvis/tensorflow-android:1.0.0
docker cp <containerId>:/file/path/within/container /host/path/target
docker cp a80d6a5002:/tensorflow/bazel-bin/tensorflow/examples/android/tensorflow_demo.apk /tmp/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store