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

Continuous integration with Docker (Android app...

Continuous integration with Docker (Android app example)

Continous integration with Docker. Based on Android app example.

Michal Moczulski

March 22, 2018
Tweet

More Decks by Michal Moczulski

Other Decks in Programming

Transcript

  1. Continuous integration • The process of continuously integrating new changes

    in the code. Every new change must be verified automatically • Prevents integrating code that is not compiling or passing tests • Allows for error detection and fixes on early stage
  2. Docker • Allows for virtualization on operating system level using

    containers • The container is a lightweight version of VM • Containers are separated from each other and totally independent • Docker is available for free(“Community Edition” on Linux, OS X and Windows)
  3. Creating Docker image • What is required to build an

    Android app? • Image must contain all tools required to build an Android application • Image is created based on Dockerfile • Images can be stored on hub.docker.com • https://github.com/mrmike/SimpleAndroidDocker
  4. Docker image • Let’s use our sample image • gradle

    clean build • https://github.com/mrmike/android-ci-sample
  5. Cache • Is downloading all dependencies for every build needed?

    • Gradle cache can be used • $GRADLE_USER_HOME/caches • Cache can be used by one container at the time • https://github.com/gradle/gradle/issues/851
  6. Travis CI • Easy configuration with YAML • We can

    take advantage of Gradle cache • Free for open source projects • https://github.com/mrmike/android-ci-sample/blob/master /.travis.yml
  7. sudo: required language: java service: - docker before_install: - docker

    pull michalmoczulski/simple-android-docker script: - ./verify-build.sh
  8. Circle CI • Easy configuration with YAML • 1500 build

    minutes for free • https://github.com/mrmike/android-ci-sample/blob/master /.circleci/config.yml
  9. Jenkins - EC2 • Jenkins instance on EC2 • Blue

    Ocean plugin • Can be tailored to your needs • Can be costly and time consuming • https://github.com/mrmike/android-ci-sample/blob/master /Jenkinsfile
  10. pipeline { agent any stages { stage('clean-build') { steps {

    sh './verify-build.sh' } } } environment { DOCKER_GRADLE_CACHE = '/path/gradle-cache' } }
  11. Summary (1/2) • All dependencies requires to build an app

    in one place(an image) • Fits any CI system supporting Docker • Scalable solution • Repeatable test environment
  12. Summary (2/2) • How to distribute an image? (Dockerfile, Docker

    Hub, Amazon ECR) • How to version the image? (tag latest may be not enough) • How to maintain the image?
  13. Links (1/2) • Simple Android Docker - Github • Android

    CI Sample App - Github • Simple Android Docker - Docker hub • docs - docker.com • Set Up a Jenkins Build Server (AWS) • Docker Basics for Amazon ECS
  14. Links (2/2) • Using Docker in Builds - Travis CI

    • CI with Docker - CircleCi.com • How is Docker different from a normal virtual machine? • Blue Ocean - Jenkins.io • Continuous Integration -ThoughtWorks.com • sdkmanager - developer.android.com