Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Build your APK beyond Docker #dockerlt

2d8205dc9c77318497ef33ba475817fe?s=47 Rize MISUMI
October 14, 2015

Build your APK beyond Docker #dockerlt

at Docker 実践 LT



October 14, 2015

More Decks by Rize MISUMI

Other Decks in Technology


  1. Build your APK beyond Docker Misumi_Rize / Docker࣮ફLT (Oct. 14,

  2. Log.d("introduction", me); → Twitter @Misumi_Rize → GitHub @MisumiRize → I'm

    not Android APK developer
  3. Software Engineer in Test

  4. Testing strategy 1. Unit tests 2. Instrumentation tests 3. Acceptance

    tests 4. Exploratory tests
  5. Testing tools 1. JUnit, Mockito 2. Espresso 3. UIAutomator, Appium

    4. Human power
  6. Testing APK is difficult → Developer specific problem → CI

    service specific problem → APK's state (SQLite, Preference, etc.)
  7. Container CI

  8. Container as CI Service → Docker as a function (Travis

    CI, CircleCI, Wercker) → Based on Docker (Drone)
  9. Docker is protocol

  10. https://hub.docker.com/r/misumirize/android-sdk https://github.com/MisumiRize/dockerfiles/tree/ master/android-sdk

  11. FROM misumirize/android-sdk RUN mkdir /project COPY . /project WORKDIR /project

    RUN echo "sdk.dir=$ANDROID_HOME" > local.properties ENTRYPOINT ["./gradlew"] CMD ["tasks"]
  12. Run unit tests and generate APK $ docker build -t

    android-build . $ docker run android-build build
  13. How can we automate Activity tests?

  14. Too slow and frustrating ARM emulator cf. Travis CI $

    echo no | android create avd --force \ --name test --target android-23 --abi armeabi-v7a $ emulator64-arm -avd test -no-skin -no-audio -no-window & $ android-wait-for-emulator $ adb shell input keyevent 82 & $ ./gradlew connectedCheck
  15. Can we connect to another host (e.g. which real device

    is connected) from container?
  16. Problem: → ./gradlew connectedCheck wraps ADB client → We can't

    configure the host of ADB client → ADB server binds to the loopback address only
  17. Solution: HAProxy

  18. None
  19. Client (container) frontend local_adb_server bind mode tcp default_backend remote_adb_server

    backend remote_adb_server mode tcp server remote01 check
  20. Server (devices connected) frontend remote_adb_server bind *:5036 mode tcp default_backend

    internal_adb_server backend internal_adb_server mode tcp server internal01 check
  21. Separating role is important

  22. https://hub.docker.com/r/misumirize/android- remote-client https://github.com/MisumiRize/dockerfiles/tree/ master/android-remote-client

  23. FROM misumirize/android-remote-client CMD ["connectedAndroidTest", "--stacktrace"]

  24. misumirize/android-remote-client ONBUILD COPY haproxy.cfg /etc/haproxy/haproxy.cfg ONBUILD COPY . /project WORKDIR

    /project ONBUILD RUN echo "sdk.dir=$ANDROID_HOME" > local.properties ENTRYPOINT ["execute-remote"]
  25. ONBUILD is awesome!

  26. But a little dirty hack is needed... build.gradle com.android.ddmlib.DdmPreferences.setTimeOut(60000)

  27. Example: Connect Docker (CircleCI) and DigitalOcean Droplet (Android Atom emulator

  28. Example https://github.com/MisumiRize/HackerNews- Android https://circleci.com/gh/MisumiRize/HackerNews- Android/22 → circle.yml → Vagrantfile

  29. Conclusion → Docker is protocol → Separating role (even forcefully)

    is important → ONBUILD is useful. Consider using ONBUILD
  30. Thank you!

  31. → Android Lineup - Shadow by Rob Bulmahn → Desastrosos

    by srgpicker → cyclotron by Robert Couse-Baker → Containing the containers by Erik Söderström → Nexus 7 with Android 5 by Yuri Samoilov → IMAG0191 by Robert → Hornby Separated Bike Lane by Paul Krueger → A Street Called Awesome by Selena N. B. H.