Docker can be used to run Android applications and tests in isolated environments called containers. This allows building and testing Android apps on any machine quickly by avoiding the need to manually install Android SDKs and other dependencies. The document discusses how Docker solves problems like setting up continuous integration environments and running UI, unit and other tests in parallel. It provides examples of fully dockerizing an Android project versus connecting devices or emulators to Docker containers. Code examples are shown for building Dockerfiles and scripts to run tests inside Docker containers.
6. 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
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
9. 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
11. 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
13. 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
15. Setup
Old good laptop with Ubuntu + Jenkins + Docker
Android app:)
With tests..?
Run Docker, run…
Don’t use OS X for CI
16. 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