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
890
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
330
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
keithyokoma
0
570
Build apps for Cars
keithyokoma
0
460
Save the state
keithyokoma
0
520
Either in Kotlin
keithyokoma
0
530
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
5k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
4.9k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
500
DX Improvements
keithyokoma
3
380
Other Decks in Technology
See All in Technology
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
740
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
530
TypeScript開発にモジュラーモノリスを持ち込む
sansantech
PRO
3
830
普通のエンジニアがLaravelコアチームメンバーになるまで
avosalmon
0
650
大規模言語モデルとそのソフトウェア開発に向けた応用 (2024年版)
kazato
2
380
12 Days of OpenAIから読み解く、生成AI 2025年のトレンド
shunsukeono_am
0
940
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
6
54k
Unlearn Product Development - Unleashed Edition
lemiorhan
PRO
2
160
mixi2 の技術スタックを探ってみる (アプリ編)
ichiki1023
0
100
20240513 - 框裡框外_文學院學生如何在AI世代安身立命 @ 淡江大學
dpys
0
570
AWS re:Invent 2024 Recap in ZOZO - Serverless で好きなものをしゃべってみた
chongmyungpark
0
830
[JAWS-UG新潟#20] re:Invent2024 -CloudOperationsアップデートについて-
shintaro_fukatsu
0
140
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
320
Optimizing for Happiness
mojombo
376
70k
How GitHub (no longer) Works
holman
312
140k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Navigating Team Friction
lara
183
15k
Agile that works and the tools we love
rasmusluckow
328
21k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
50k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
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