Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Android meets Docker
Jing Li
ROME - APRIL 13/14 2018
Founded in 2009
13 countries
&
70+ cities
~ 120K
drivers
~ 11M active
passengers
Hamburg
Barcelona
Berlin
600+ employees
Developer Story
Pain in the Admin
provision ∞ machines
Containerization vs Virtualization
Why Docker?
Resource Isolation
Supported OS
Boot / Stop Time
Size
Low Extreme
Linux
Seconds
MB
*
Minutes
GB
Where the problem comes
Infer - A tool to detect bugs in Java and ... code.
Infer (http://fbinfer.com/) by Facebook, Inc.
...
Dockerfile Best Practices
" Single responsibility
○ use compose for orchestration
" Minimize the number of layers
○ layer ...
Different Approaches
" BTRFS storage driver
" One image per Android API level
" Mount SDK volume
Solution for SDK update
Mount SDK volume in container
minimal by Bakunetsu Kaito from the Noun Project, spring by Free Fai...
NFS
✅ In one place
❓ Performance
No concurrent writing
Benchmark
Performance Comparison
2 build types, 107 unit tests ( x2 = 214 ), 2 UI tests
./gradlew clean check :demo:connectedAndroid...
Android Devices
" ARM emulator
" x86 emulator (requires KVM)
" USB (needs privileged mode, ⛔ for macOS)
" Wifi
" Cloud sol...
Emulator
VNC
Image size
" without VNC-server
○ 563 MB
" with VNC-server
○ 626 MB
Performance of 📱
2 UI tests
ARM emulator @🐳 2 mins 4.615 secs
x86 emulator @🐳 (on Linux Host) 23.497 secs
Genymotion 25.33...
Out Of Memory
Memory Matters
_JAVA_OPTIONS
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
Exit Code 137 = 128 + 9 = S...
" Set up env
○ /root/.ssh/environment
" Authorization
○ /root/.ssh/authorized_keys
SSH
Jenkins Env Var
" Global level
○ Configure System -> Global properties -> Environment variables
" Node level
○ Manage Node...
Can we get any better?
Gradle distribution
Gradle distributions mirror server
" From: gradle/wrapper/gradle-wrapper.properties
" To: ~/.gradle/wrapper/dists
" SSL ce...
And better?
Gradle caches
○ Don’t waste time downloading dependencies
○ ~/.gradle/caches/
Compiling (https://xkcd.com/303/...
Reveal machine-dependent problem
" Encoding problem
○ expected:<Hall[��]chen> but was:<Hall[ö]chen>
" Hard coded Timezone ...
What else for mobile
" Integration Test
○ Prod / Test server
■ unreliable network
■ complex setup
○ Docker
■ out of the bo...
Hiring
" 👍 Offices in Hamburg, Berlin, Barcelona and etc.
" 👍 Visa sponsor, offer ✈ 🏠
○ Android Developers
○ iOS Developer...
Grazie
thyrlian
Docker Image:
https://github.com/thyrlian/AndroidSDK
thyrlian
Android meets Docker - Jing Li - Codemotion Rome 2018
Upcoming SlideShare
Loading in …5
×

Android meets Docker - Jing Li - Codemotion Rome 2018

492 views

Published on

CI is an eternal topic in software engineering, it is still evolving for mobile. With an introduction to Docker, and a full-fledged Docker image for Android, this presentation will guide you through all facts about using Docker for Android CI - benefits, limitations, pitfalls, tweaks, and performance. Follow me, you can build your own Acme CI at zero cost. Last but not least, there are some other tips about how Docker could help your mobile engineering.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Android meets Docker - Jing Li - Codemotion Rome 2018

  1. 1. Android meets Docker Jing Li ROME - APRIL 13/14 2018
  2. 2. Founded in 2009 13 countries & 70+ cities ~ 120K drivers ~ 11M active passengers Hamburg Barcelona Berlin 600+ employees
  3. 3. Developer Story
  4. 4. Pain in the Admin provision ∞ machines
  5. 5. Containerization vs Virtualization
  6. 6. Why Docker? Resource Isolation Supported OS Boot / Stop Time Size Low Extreme Linux Seconds MB * Minutes GB
  7. 7. Where the problem comes Infer - A tool to detect bugs in Java and ... code. Infer (http://fbinfer.com/) by Facebook, Inc. Update Android SDK in Docker container ☠ AUFS
  8. 8. Dockerfile Best Practices " Single responsibility ○ use compose for orchestration " Minimize the number of layers ○ layer = intermediate image, supports caching " Size matters, use what you have ○ Install & un- by separated steps will ⇧ image size " Readability
  9. 9. Different Approaches " BTRFS storage driver " One image per Android API level " Mount SDK volume
  10. 10. Solution for SDK update Mount SDK volume in container minimal by Bakunetsu Kaito from the Noun Project, spring by Free Fair & Healthy from the Noun Project, Save by Rflor from the Noun Project, Share by Matteo Della Chiesa from the Noun Project
  11. 11. NFS ✅ In one place ❓ Performance No concurrent writing
  12. 12. Benchmark
  13. 13. Performance Comparison 2 build types, 107 unit tests ( x2 = 214 ), 2 UI tests ./gradlew clean check :demo:connectedAndroidTest On-premises Docker (w/ cached AndroidSDK) 6 mins 48.0 secs Other online CI solutions (w/o optimization) > 10 mins
  14. 14. Android Devices " ARM emulator " x86 emulator (requires KVM) " USB (needs privileged mode, ⛔ for macOS) " Wifi " Cloud solutions (e.g. Genymotion Cloud)
  15. 15. Emulator
  16. 16. VNC Image size " without VNC-server ○ 563 MB " with VNC-server ○ 626 MB
  17. 17. Performance of 📱 2 UI tests ARM emulator @🐳 2 mins 4.615 secs x86 emulator @🐳 (on Linux Host) 23.497 secs Genymotion 25.335 secs
  18. 18. Out Of Memory
  19. 19. Memory Matters _JAVA_OPTIONS -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap Exit Code 137 = 128 + 9 = SIGKILL = Killed 1 = SIGHUP = Hangup Comment killed by the kernel OOM killer JVM terminates the program and exits JVM is not container aware
  20. 20. " Set up env ○ /root/.ssh/environment " Authorization ○ /root/.ssh/authorized_keys SSH
  21. 21. Jenkins Env Var " Global level ○ Configure System -> Global properties -> Environment variables " Node level ○ Manage Nodes -> Configure Node -> Node Properties -> Environment variables " Job level ○ Configure Job -> Build -> Build Step -> Execute shell ○ Plugin: Environment Injector -> Inject variables to the build process / as a build step
  22. 22. Can we get any better? Gradle distribution
  23. 23. Gradle distributions mirror server " From: gradle/wrapper/gradle-wrapper.properties " To: ~/.gradle/wrapper/dists " SSL certificate - needs to be trusted by Java keystore " /etc/hosts
  24. 24. And better? Gradle caches ○ Don’t waste time downloading dependencies ○ ~/.gradle/caches/ Compiling (https://xkcd.com/303/) by xkcd
  25. 25. Reveal machine-dependent problem " Encoding problem ○ expected:<Hall[��]chen> but was:<Hall[ö]chen> " Hard coded Timezone in test ○ expected:2099-12-31T00:00:00.0000+0200
 but was: 2099-12-31T00:00:00.0000+0000 " File & Path ○ File#listFiles() -> File[] (sort order depends on OS)
  26. 26. What else for mobile " Integration Test ○ Prod / Test server ■ unreliable network ■ complex setup ○ Docker ■ out of the box for mobile dev " Something else ○ Serverless ( Kotlin, Swift ) - reuse 📱 code
  27. 27. Hiring " 👍 Offices in Hamburg, Berlin, Barcelona and etc. " 👍 Visa sponsor, offer ✈ 🏠 ○ Android Developers ○ iOS Developers ○ SDET ○ Backend / Frontend / Data / * Engineers https://de.mytaxi.com/jobs
  28. 28. Grazie thyrlian Docker Image: https://github.com/thyrlian/AndroidSDK thyrlian

×