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

Android SDK with Docker

Junki Kaneko
September 21, 2017

Android SDK with Docker

Junki Kaneko

September 21, 2017
Tweet

More Decks by Junki Kaneko

Other Decks in Technology

Transcript

  1. Android SDK with Docker Android Test Night #1 September 21,

    2017 Kaneko Junki SWET G DeNA Co., Ltd.
  2. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Profile

    • Name ◦ Kaneko Junki • Belong ◦ Company: DeNA ◦ Section: SWET G • SNS ◦ Github: theoden9014 ◦ twitter: @theoden9014
  3. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Q:

    ビルドマシンのメンテナンスに 消耗していませんか?
  4. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Q:

    CI環境の独特のセットアップ処理に 消耗していませんか?
  5. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. What’s

    Docker ? • Software run isolated on a shared operating system • Build Docker Image by Dockerfile • Docker Image can managed repository
  6. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Why

    Docker ? • Transplantability ◦ Working almost Platform ▪ OS:Linux, MacOS, Windows ▪ CI: CircleCI, TravisCI, etc... • Fast ◦ Use Cache • Standard Technology ◦ Many Knowledge
  7. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. ATTENTION

    ! Reference: https://developer.android.com/studio/terms.html 3. SDK License from Google 3.1 Subject to the terms of the License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, and non-sublicensable license to use the SDK solely to develop applications for compatible implementations of Android. 3.2 You may not use this SDK to develop applications for other platforms (including non-compatible implementations of Android) or to develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of Android, provided that this SDK is not used for that purpose. 3.3 You agree that Google or third parties own all legal right, title and interest in and to the SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you. 3.4 You may not use the SDK for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the SDK or any part of the SDK.
  8. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. ATTENTION

    ! Do not Upload Docker Image to Public Repository
  9. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Dockerfile

    Sample (AndroidSDK) • My Sample ◦ https://github.com/theoden9014/android-sdk-alpine • Uber ◦ https://github.com/uber-common/android-build-environment • AppUnite ◦ https://github.com/appunite/docker • bitrise.io ◦ https://github.com/bitrise-docker/android
  10. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Docker

    Image Layer • Android SDK Docker Image ◦ Android Project Docker image
  11. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Dockerfile

    in Android Project FROM ${AndroidSDKDockerImageName} RUN mkdir -p /tmp/gradle/app COPY gradlew /tmp/gradle/gradlew COPY gradle /tmp/gradle/gradle COPY build.gradle /tmp/gradle/build.gradle COPY gradle.properties /tmp/gradle/gradle.properties COPY settings.gradle /tmp/gradle/settings.gradle COPY app/build.gradle /tmp/gradle/app/build.gradle WORKDIR /tmp/gradle RUN ./gradlew ADD . /project WORKDIR /project CMD [“./gradlew tasks”]
  12. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Dockerfile

    Sample (Emulator) • https://github.com/butomo1989/docker-android ◦ Support Appium • https://github.com/tracer0tong/android-emulator
  13. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Run

    Emulator & Test • Run Emulator ◦ docker run -d -it --name android-container ${EmulatorDockerImage} • Run Test ◦ docker run -it -v $(pwd)/entrypoint.sh:/product/entrypoint.sh \ --link android-container --entrypoint /product/entrypoint.sh \ ${AndroidProjectDockerImage} ./gradlew connectedAndroidTest ◦ entrypoint.sh ▪ #!/bin/bash adb kill-server && adb connect android-container:5555 && exec “$@”
  14. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Run

    Emulator & Test • Run Emulator ◦ docker run -d -it --name android-container ${EmulatorDockerImage} • Run Test ◦ docker run -it -v $(pwd)/entrypoint.sh:/product/entrypoint.sh \ --link android-container --entrypoint /product/entrypoint.sh \ ${AndroidProjectDockerImage} ./gradlew connectedAndroidTest ◦ entrypoint.sh ▪ #!/bin/bash adb kill-server && adb connect android-container:5555 && exec “$@” • Time ◦ with Docker: 450 s / 15 TestCase ◦ with MacOS: 270 s / 15 TestCase Nested VM so very slowly (Docker for Mac)
  15. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Why

    Docker ? • Transplantability ◦ Working almost Platform ▪ OS:Linux, MacOS, Windows ▪ CI: CircleCI, TravisCI, etc... • Fast ◦ Use Cache • Standard Technology ◦ Many Knowledge ?
  16. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. LET’S

    DEVICE FARM • Firebase Test Lab • AWS Device Farm • OpenSTF • etc...
  17. * Copyright (C) 2017 DeNA Co.,Ltd. All Rights Reserved. Finally

    • Need knowledge of Serverside ◦ Difficult for Android Engineer • Need knowledge of Docker ◦ Make builds faster • Use DeviceFarm if run test • There is no need to forcibly introduce