How do we apply Docker
to Android
Docker & Android
UA Mobile | Volodymyr Bratashchuk | 6.04.2019
Content
What is Docker?
What pain does it solve?
How-to?
Demo
Q&A
What is Docker?
What is it so special about Docker?
What is it so special
about Docker?
Common VM vs Docker: house vs appartment
Appartment:
Go isolated process + System parts + Magic
Best tasting on Linux host
Advantages:
Highly configurable to our needs
Spins up in seconds
Takes care of resources
Docker building
blocks
Dockerfile:
Commands: FROM, ADD, RUN, ENV,
Each creates a layer(like commit in Git)
docker build – builds image from Dockerfile
docker run – start process from image
docker exec – executes command inside process
docker-machine – operate with VMs like VirtualBox,
DigitalOcean, Azure, AWS
Docker Hub like Github
Application
What pain does it solve?
CI/Automated tests
How easy is it to setup machine to build Android project?
Download Android SDK
sdkmanager install dependencies
Different types of tests needs to run in parallel
UI, Espresso, Unit
Daily, pipeline, regression…
Plug-n-play
No need to install anything on your freshy CI machine
How is it better than CI services like Circle, Travis?
We don’t have money for this
We can’t give them the code
What to Dockerize?
Depends on what you need to and can do?
Connect your
device
Pros
Quick setup
Most lightweight in terms of Docker
Close to real world environment
Cons
Hey we need a dedicated device[s]
docker run -v /dev/bus/usb:/dev/bus/usb
DockerHost
Emulator inside
container
Pros
Quick setup
Container is everything we need
Cons
May take time to create/find image
thedrhax/android-avd
Pretty heavy-weight container
<nothing>
DockerHost
Docker
Emulator on the
host
Pros
May run on Mac OS host
Cons
Need to install SDK on the host
docker run -p 5555:5555 --expose 5555
docker exec adb connect host.docker.internal
Host
Into deep
Implementation details
Setup
Old good laptop with Ubuntu + Jenkins + Docker
Android app:)
With tests..?
Run Docker, run…
Don’t use OS X for CI
Design
dockerized_*.sh script
does the same as common Android .circle config
github.com/vbevans94/docker-android
Build from Dockerfile or pull from DockerHub?
Dockerfile is more flexible
pull is more correct solution and also faster
but you can have both
Show me the code
Interactive mode
До чого прикладати Docker в Android? - UA Mobile 2019

До чого прикладати Docker в Android? - UA Mobile 2019

  • 1.
    How do weapply Docker to Android
  • 2.
    Docker & Android UAMobile | Volodymyr Bratashchuk | 6.04.2019
  • 3.
    Content What is Docker? Whatpain does it solve? How-to? Demo Q&A
  • 4.
    What is Docker? Whatis it so special about Docker?
  • 6.
    What is itso special about Docker? Common VM vs Docker: house vs appartment Appartment: Go isolated process + System parts + Magic Best tasting on Linux host Advantages: Highly configurable to our needs Spins up in seconds Takes care of resources
  • 7.
    Docker building blocks Dockerfile: Commands: FROM,ADD, RUN, ENV, Each creates a layer(like commit in Git) docker build – builds image from Dockerfile docker run – start process from image docker exec – executes command inside process docker-machine – operate with VMs like VirtualBox, DigitalOcean, Azure, AWS Docker Hub like Github
  • 8.
  • 9.
    CI/Automated tests How easyis it to setup machine to build Android project? Download Android SDK sdkmanager install dependencies Different types of tests needs to run in parallel UI, Espresso, Unit Daily, pipeline, regression… Plug-n-play No need to install anything on your freshy CI machine How is it better than CI services like Circle, Travis? We don’t have money for this We can’t give them the code
  • 10.
    What to Dockerize? Dependson what you need to and can do?
  • 11.
    Connect your device Pros Quick setup Mostlightweight in terms of Docker Close to real world environment Cons Hey we need a dedicated device[s] docker run -v /dev/bus/usb:/dev/bus/usb DockerHost
  • 12.
    Emulator inside container Pros Quick setup Containeris everything we need Cons May take time to create/find image thedrhax/android-avd Pretty heavy-weight container <nothing> DockerHost
  • 13.
    Docker Emulator on the host Pros Mayrun on Mac OS host Cons Need to install SDK on the host docker run -p 5555:5555 --expose 5555 docker exec adb connect host.docker.internal Host
  • 14.
  • 15.
    Setup Old good laptopwith Ubuntu + Jenkins + Docker Android app:) With tests..? Run Docker, run… Don’t use OS X for CI
  • 16.
    Design dockerized_*.sh script does thesame as common Android .circle config github.com/vbevans94/docker-android Build from Dockerfile or pull from DockerHub? Dockerfile is more flexible pull is more correct solution and also faster but you can have both
  • 17.
    Show me thecode Interactive mode