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
320
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
keithyokoma
0
560
Build apps for Cars
keithyokoma
0
460
Save the state
keithyokoma
0
510
Either in Kotlin
keithyokoma
0
520
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
5k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
4.9k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
490
DX Improvements
keithyokoma
3
380
Other Decks in Technology
See All in Technology
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
Password-less Journey - パスキーへの移行を見据えたユーザーの準備 @ AXIES 2024
ritou
3
1.4k
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
360
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
230
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
160
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
420
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
podman_update_2024-12
orimanabu
1
260
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1k
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
243
12k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
For a Future-Friendly Web
brad_frost
175
9.4k
Embracing the Ebb and Flow
colly
84
4.5k
Building Your Own Lightsaber
phodgson
103
6.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Building Applications with DynamoDB
mza
91
6.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
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