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
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
4
530
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
Taming you application's environments
salaboy
0
180
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
870
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
330
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
230
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Speed Design
sergeychernyshev
24
610
Designing the Hi-DPI Web
ddemaree
280
34k
Designing for Performance
lara
604
68k
Unsuck your backbone
ammeep
668
57k
Teambox: Starting and Learning
jrom
133
8.8k
Optimizing for Happiness
mojombo
376
70k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Navigating Team Friction
lara
183
14k
Being A Developer After 40
akosma
86
590k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
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