Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Automation with Wercker and Container Builder
Search
Keishin Yokomaku
March 24, 2017
Technology
1
870
Automation with Wercker and Container Builder
Automate not only your app but also your build env.
Keishin Yokomaku
March 24, 2017
Tweet
Share
More Decks by Keishin Yokomaku
See All by Keishin Yokomaku
One screen, many BottomSheets
keithyokoma
0
300
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
keithyokoma
0
530
Build apps for Cars
keithyokoma
0
450
Save the state
keithyokoma
0
500
Either in Kotlin
keithyokoma
0
510
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
4.9k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
4.8k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
490
DX Improvements
keithyokoma
3
380
Other Decks in Technology
See All in Technology
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
Lexical Analysis
shigashiyama
1
150
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
260
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.2k
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
130
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
900
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6.1k
Fireside Chat
paigeccino
34
3k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Writing Fast Ruby
sferik
627
61k
Producing Creativity
orderedlist
PRO
341
39k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Raft: Consensus for Rubyists
vanstee
136
6.6k
4 Signs Your Business is Dying
shpigford
180
21k
Music & Morning Musume
bryan
46
6.2k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Designing for Performance
lara
604
68k
Transcript
Automation with Wercker and Container Builder Keishin Yokomaku / shibuya.apk
#13
Automation with Wercker and Container Builder About Me ▸ Keishin
Yokomaku ▸ Drivemode, Inc. / Principal Engineer ▸ KeithYokoma: GitHub / Twitter / Qiita / Tumblr / Stack Overflow ▸ Books: Mobile App Dev Guide / Android Academia / Grimoire of Android ▸ Fun: Gymnastics / Cycling / Photography / Motorsport ▸ Today’s Quote: “Power is everything.” 2
Automation with Wercker and Container Builder 3
4 “Wercker͍͍ͧ”
Automation with Wercker and Container Builder Wercker? ▸ Docker-native CI/CD
Automation Platform ▸ ࣗಈͰ Docker ίϯςφΛςετɺσϓϩΠͰ͖ΔαʔϏε ▸ Docker ΠϝʔδΛ pull ͖ͯͯ͠ίϯςφΛ্ཱͪ͛Δ ▸ ίϯςφͰίϚϯυΛ࣮ߦ͢Δ ▸ ύΠϓϥΠϯͰςετͱσϓϩΠΛͰ͖Δ ▸ ςετ͕ਖ਼ৗऴྃͨ͠ͱ͖ͷΈσϓϩΠ͕࣮ߦ͞ΕΔ 5
Automation with Wercker and Container Builder Wercker for Android CI
▸ Docker Πϝʔδ͑͋͞ΕϏϧυ͕Ͱ͖Δ ▸ Android ΞϓϦΛϏϧυ͢ΔͨΊʹඞཁͳͷ͕͋Ε… ▸ Android SDK & NDK ▸ Java ▸ etc… 6
Automation with Wercker and Container Builder Wercker for Android CD
▸ Android ΞϓϦͷσϓϩΠ => apk ͷ৴ ▸ apk Λ৴ͯ͘͠ΕΔαʔϏεʹσϓϩΠ͢Ε… ▸ DeployGate ▸ fastlane ▸ etc… 7
8 “શʹཧղͨ͠”
Automation with Wercker and Container Builder Steps 1.Dockerfile ͔Β Docker
ΠϝʔδΛϏϧυ 2.Ϗϧυͨ͠ΠϝʔδΛ dockerhub ͳͲͷϨδετϦʹొ 3.Ϗϧυ͍ͨ͠ϦϙδτϦʹwercker.yml Λஔ 4.Wercker ͷઃఆ 9
Automation with Wercker and Container Builder Building a Docker image
▸ Dockerfile Λͭ͘Ζ͏(ྫ) ▸ Ubuntu Λϕʔεʹ ▸ Android SDK ͱ Java ΛΠϯετʔϧͯ͠ ▸ ඞཁͳڥมΛ͑ͨΠϝʔδ ▸ e.g. http://bit.ly/2ngAz0S 10
Automation with Wercker and Container Builder Pushing the image to
a registry ▸ Wercker ͕ѻ͑ΔϨδετϦ ▸ Docker Hub ▸ Google Container Registry ▸ Amazon ECR ▸ Private Registry(quay.io) ▸ ϓϥΠϕʔτϦϙδτϦʹ͠·͠ΐ͏ (http://bit.ly/2nuwkz9) 11
Automation with Wercker and Container Builder Build an image using
‘docker-machine' (mac) $ docker-machine start image-builder (mac) $ docker-machine ssh image-builder (docker-machine) $ ls Dockerfile (docker-machine) $ docker build -t account/repository:tag . (docker-machine) $ docker login (docker-machine) $ docker push account/repository:tag (docker-machine) $ exit (mac) $ docker-machine stop image-builder 12
Automation with Wercker and Container Builder Configure wercker.yml ▸ Android
ΞϓϦͷϦϙδτϦʹ YAML ϑΝΠϧΛஔ͘ ▸ ໊લඞͣ wercker.yml ▸ ϏϧυɺσϓϩΠͦΕͧΕͷϋογϡʹϏϧυʹඞཁͳखॱΛॻ͘ ▸ ϏϧυͱσϓϩΠͰҟͳΔ Docker ΠϝʔδΛ༻Մೳ 13
Automation with Wercker and Container Builder Configure wercker.yml build: box:
id: account/repository username: $USERNAME password: $PASSWORD tag: tag steps: - script: name: assemble code: | ./gradlew —stacktrace —project-cache-dir=$WERCKER_CACHE_DIR assemble - script: name: test code: | ./gradlew —stacktrace —project-cache-dir=$WERCKER_CACHE_DIR test lint 14
Automation with Wercker and Container Builder Configure wercker.yml build: box:
id: account/repository username: $USERNAME password: $PASSWORD tag: tag steps: - script: name: assemble code: | ./gradlew —stacktrace —project-cache-dir=$WERCKER_CACHE_DIR assemble - script: name: test code: | ./gradlew —stacktrace —project-cache-dir=$WERCKER_CACHE_DIR test lint 15
Automation with Wercker and Container Builder Configure wercker.yml build: box:
id: account/repository username: $USERNAME password: $PASSWORD tag: tag steps: - script: name: assemble code: | ./gradlew —stacktrace —project-cache-dir=$WERCKER_CACHE_DIR assemble - script: name: test code: | ./gradlew —stacktrace —project-cache-dir=$WERCKER_CACHE_DIR test lint 16
Automation with Wercker and Container Builder Tips ▸ 1ͭͷεςοϓ10ͰλΠϜΞτ ▸
ίϚϯυͷ࣮ߦ͕͘ͳΔͱ͖͚Δ ▸ Wercker ͷ Web ΠϯλϑΣʔεͰͷग़ྗ͕͔ͳΓγϯϓϧ ▸ ࠔͬͨͱ͖ʹ͍͍ͨใ echo Ͱग़ྗ͢ΔεςοϓΛ࡞Δ ▸ ϩάग़ྗ͕͍ͱ Web ΠϯλϑΣʔε͕ܹॏͳͷͰదٓௐ 17
Automation with Wercker and Container Builder Saving artifacts ▸ after-steps
ʹखॱΛॻ͘ ▸ ڥมʹอଘॴ͕ఆٛͯ͋͠Δ ▸ $WERCKER_REPORT_ARTIFACTS_DIR ▸ ೖΕ͍ͨͷ͚ͩ cp ͢Δ ▸ อଘͨ͠Ռ Web ͔ΒμϯϩʔυͰ͖Δ ▸ ॴ͕͔ΓͮΒ͍ͷͰҙ 18
Automation with Wercker and Container Builder Saving artifacts 19
Automation with Wercker and Container Builder Saving artifacts after-steps: -
script: name: save artifacts code: | ls -la ./app/build/outputs/ cp -r ./app/build/outputs/* ${WERCKER_REPORT_ARTIFACTS_DIR} cp -r ./app/build/reports/* ${WERCKER_REPORT_ARTIFACTS_DIR} 20
Automation with Wercker and Container Builder Saving artifacts after-steps: -
script: name: save artifacts code: | ls -la ./app/build/outputs/ cp -r ./app/build/outputs/* ${WERCKER_REPORT_ARTIFACTS_DIR} cp -r ./app/build/reports/* ${WERCKER_REPORT_ARTIFACTS_DIR} 21
Automation with Wercker and Container Builder Connect Wercker with GitHub
22
Automation with Wercker and Container Builder Connect Wercker with GitHub
▸ ϦϙδτϦΛબΜͰ… ▸ ΦʔφʔΛબΜͰ… ▸ σϓϩΠΩʔΛՃͯ͠… ▸ public ͳϓϩδΣΫτͷ߹ https ܦ༝ͰΞΫηε͢ΔઃఆͰ OK ▸ ྃʂ 23
24
Automation with Wercker and Container Builder ӡ༻͢Δͱݟ͑ͯ͘Δ Wercker ͷखؒ ▸
SDK ͷΞοϓσʔταϙʔτϦϙδτϦͷΞοϓσʔτ ▸ Docker ΠϝʔδΛ࡞Γ͢͜ͱʹͳΔ͕…ʁ ▸ ຖճ docker-machine ͰϏϧυ…ʁ ▸ docker-machine ͱ Android Emulator ಉ࣌ʹಈ͔ͤͳ͍ͧ…ʁ ▸ Πϝʔδ࡞Δ͚ͩͰ 10 Ҏ্͔͔ΔΜ͚ͩͲ…ʁ ▸ λάͷཧΛࣗͰߟ͑Δͷ໘͍͘͞Μ͚ͩͲ…ʁ 25
26
27 “ͦ͜ͰContainer BuilderͰ͢Α”
Automation with Wercker and Container Builder Container Builder? ▸ ͜ΕԿʁ
▸ Google ͷαʔϏε ▸ Dockerfile ΛΘͨ͢ͱࣗಈͰ Docker ΠϝʔδΛ࡞ͬͯϨδετϦʹొͯ͠ ͘ΕΔ͍ͭ͢͝ 28
Automation with Wercker and Container Builder Container Builder? ▸ ͜ΕԿʁ
▸ Google ͷαʔϏε ▸ Dockerfile ΛΘͨ͢ͱࣗಈͰ Docker ΠϝʔδΛ࡞ͬͯϨδετϦʹొͯ͠ ͘ΕΔ͍ͭ͢͝ 29
Automation with Wercker and Container Builder Container Builder ▸ Πϝʔδͷ
TAG ͷཧํ๏ΛઃఆͰ͖Δ ▸ ݻఆͰ latest ͷ·· ▸ git ͷίϛοτ ID Λλάʹ͢Δ ▸ etc… ▸ GitHub ͱ࿈ܞͰ͖Δ 30
Automation with Wercker and Container Builder Workflow of updating Docker
image ▸ Dockerfile Λฤू ▸ ίϛοτΛ push ▸ Container Builder ͕ϏϧυΛ࢝ΊΔ ▸ ྃͨ͠Β৽͍͠λάΛ wercker.yml ʹઃఆ͢Δ 31
32 “શʹཧղͨ͠”
Automation with Wercker and Container Builder Configure Container Builder ▸
Google Cloud Console ͔Β Container Registry Λ։͘ ▸ Build triggers ͔Β GitHub ͷϦϙδτϦΛબͯ͠τϦΨʔΛઃఆ ▸ Ͳͷϒϥϯνͷ push ͰϏϧυΛ࢝ΊΔ͔ ▸ Dockerfile ͷॴ ▸ Πϝʔδ໊ 33
Automation with Wercker and Container Builder Configure Container Builder ▸
Dockerfile ͷϏϧυ ▸ 10Ҏ্͔͔ΔͱλΠϜΞτ͢Δ ▸ cloudbuild.yaml Λ͔ͭͬͯௐ͢ΔΑ͏มߋ 34
Automation with Wercker and Container Builder cloudbuild.yaml timeout: 40m steps:
- name: gcr.io/cloud-builders/docker args: ['build', '--tag=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] images: ['gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'] 35
Automation with Wercker and Container Builder cloudbuild.yaml timeout: 40m steps:
- name: gcr.io/cloud-builders/docker args: ['build', '--tag=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] images: ['gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'] 36
Automation with Wercker and Container Builder cloudbuild.yaml timeout: 40m steps:
- name: gcr.io/cloud-builders/docker args: ['build', '--tag=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] images: ['gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'] 37
Automation with Wercker and Container Builder cloudbuild.yaml timeout: 40m steps:
- name: gcr.io/cloud-builders/docker args: ['build', '--tag=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] images: ['gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'] 38
Automation with Wercker and Container Builder cloudbuild.yaml timeout: 40m steps:
- name: gcr.io/cloud-builders/docker args: ['build', '--tag=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] images: ['gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'] 39
Automation with Wercker and Container Builder Change wercker.yml ▸ Google
Container Registry ͔ΒҾͬுͬͯ͘ΔΑ͏ʹ͢Δ ▸ JSON Ͱೝূ͢ΔํࣜʹͳΔ ▸ username ඞͣ _json_key ▸ ೝূใͷೖͬͨ JSON ڥมʹೖΕ͓ͯ͘ ▸ gcr.io ΛϨδετϦʹࢦఆ͢Δ 40
Automation with Wercker and Container Builder Change wercker.yml build: box:
id: account/repository username: $USERNAME password: $PASSWORD tag: tag box: id: gcr.io/<PROJECT_ID>/<IMAGE_NAME> username: _json_key passwrod: $GCR_JSON_KEY_FILE registry: https://gcr.io tag: <TAG> 41
Automation with Wercker and Container Builder $GCR_JSON_KEY_FILE as Environment variable
in Wercker CI { “type”: “service_account”, “project_id”: “PROJECT_ID”, “private_key_id”: “hogefugapiyofoobarbaz”, “private_key”: “——-BEGIN PRIVATE KEY——-\nhogehoge\n——-END PRIVATE KEY——-” “client_email”: “
[email protected]
” …… } 42
Automation with Wercker and Container Builder Wercker + Container Builder
▸ ϏϧυڥΛ Docker Πϝʔδʹ٧ΊࠐΊΔ ▸ ϏϧυɾσϓϩΠڥʹԿ͕ඞཁ͔ίʔυʹམͱͤΔ ▸ ίʔυʹམͱͨ͠ Dockerfile ΛϦϏδϣϯཧͰ͖Δ ▸ ΠϝʔδΛͬͯ CI/CD ͕Ͱ͖Δ ▸ ΠϝʔδΛϗετͯ͘͠ΕΔॴ͔Β pull ͢Δ͚ͩͰ͑Δ 43
Automation with Wercker and Container Builder Wercker + Container Builder
▸ CI ڥΛ CI/CD ͢Δ ▸ खݩͷ PC ͷϦιʔεΛΘͣʹΠϝʔδΛϏϧυͰ͖Δ ▸ Docker ΠϝʔδͷϦϏδϣϯཧΛࣗಈԽͰ͖Δ ▸ ڥΛม͑Δ࣌ TAG Λม͑Δ͚ͩ 44
Automation with Wercker and Container Builder Keishin Yokomaku / shibuya.apk
#13