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
860
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
280
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
keithyokoma
0
510
Build apps for Cars
keithyokoma
0
430
Save the state
keithyokoma
0
490
Either in Kotlin
keithyokoma
0
490
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
4.9k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
4.7k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
470
DX Improvements
keithyokoma
3
370
Other Decks in Technology
See All in Technology
FastAPIでのasync defとdefの使い分け
takashi1029
6
1.8k
小さな勉強会の始め方、広げ方、あるいは友達の作り方 / How to Start, Grow, and Build Connections with Small Study Groups
ar_tama
2
870
Vista FinderMx
jtes
0
160
XP matsuri 2024 - 銀河英雄伝説に学ぶ
kawaguti
PRO
3
500
不感対策ソリューション
jtes
0
230
スクラム導入の舞台裏:QAエンジニアがスクラムマスターになるまで
bubo1201
0
110
10Xでのデータ基盤の変遷とこれから: データマネジメントのリアル 〜BtoB企業3社の歩みとこれから〜
10xinc
6
1.2k
C# 13 / .NET 9 の新機能 (RC 1 時点)
nenonaninu
1
1.1k
【shownet.conf_】トポロジ図の歩き方
shownet
PRO
0
360
映像・音声伝送システム
jtes
0
200
Oracle GoldenGate 23ai 導入Tips
oracle4engineer
PRO
1
200
Webセキュリティのあるきかた
akiym
10
2.7k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How GitHub (no longer) Works
holman
311
140k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Building a Scalable Design System with Sketch
lauravandoore
459
32k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
38
2.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
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