Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GitHub Universe After Party Thailand 2023 - Fas...
Search
Karn Wong
November 01, 2023
Technology
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GitHub Universe After Party Thailand 2023 - Faster deployments with multi-stage build caching
Karn Wong
November 01, 2023
Transcript
25 slides
Faster deployments with multi- stage build caching Here’s to incremental
deployments.
About me kahnwong Karnsiree Wong karnwong.me Head of Platform Engineering
@Baania Often known as DevSecMLFinDataOps Faster deployments -> Faster iterations I love automation
CI/CD workflow
Dockerfile FROM node:18 WORKDIR /opt/build COPY package.json . COPY yarn.lock
. RUN yarn install COPY . . RUN yarn build EXPOSE 3000 CMD [ "yarn", "start", "-H", "0.0.0.0" ]
GitHub Actions Buildx - name: Build and tag image uses:
docker/build-push-action@v5 with: context: . builder: ${{ steps.buildx.outputs.name }} file: Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} provenance: false
But we can cache docker layers
GitHub Actions Buildx with cache - name: Build and tag
image uses: docker/build-push-action@v5 with: context: . builder: ${{ steps.buildx.outputs.name }} file: Dockerfile push: true cache-from: type=gha # add this cache-to: type=gha,mode=max # add this tags: ${{ steps.meta.outputs.tags }} provenance: false
Buildx Buildx with cache
How do we know that we’re using cache?
Check GitHub Actions caches from all workflows
What about image size?
Dockerfile with multi-stage build # --------------- builder --------------- # FROM
node:18 AS builder WORKDIR /opt/build COPY package.json . COPY yarn.lock . RUN yarn install COPY . . RUN yarn build # --------------- package --------------- # FROM node:18-alpine AS deploy WORKDIR /app COPY --from=builder /opt/build/.next ./.next COPY --from=builder /opt/build/node_modules ./node_modules COPY --from=builder /opt/build/public ./public COPY --from=builder /opt/build/next.config.js ./ COPY --from=builder /opt/build/package.json ./ EXPOSE 3000 CMD [ "yarn", "start", "-H", "0.0.0.0" ]
Why multi-stage build? yarn build creates a lot of temporary
files We don’t need those "temporary files" for yarn start ` ` ` `
Let’s guess the image size!
Normal build Multi-stage build
How much can we save? Build time 30s per build
(from 3m24s to 2m57s) Image storage (compressed) 300MB per image (from 450MB to 150MB)
Any questions?
Ready for cost reduction? If we deploy 150 times /
month
Cost breakdown Service No Cache With Cache GitHub Actions (Runtime)
3m24s * 150 = 510m 2m57s * 150 = 442.5m Service Normal Build Multi-Stage Build ECR (Storage) 450MB * 150 = 66GB 150MB * 150 = 22GB ECR (Cost) 150MB * 150 = 22GB 22GB * 0.10 USD = 2.2 USD In total, we can save 67.5 minutes and 4.4 USD per month.
I know you love pretty charts
GitHub Actions Cache can also be used with runtimes steps:
- uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 18 cache: 'yarn' - run: yarn install - run: yarn build
Let’s revisit CI/CD workflow again
Any questions?
Summary GitHub Actions cache can be used with docker image
build and setup actions Multi-stage build can drastically reduce image size (in turn, reducing image storage cost) These lead to faster CI/CD run time and faster deployments During PR review, automated checks can be done faster as well
Check out the slides and repo!
More Decks by Karn Wong
See All by Karn Wong
Python Developer Day 2026 - Demystifying Agent Sandbox
kahnwong
0
54
Global Azure 2026 - Securing VM Access On Azure
kahnwong
0
80
AgentCon Bangkok 2026 - How to Stay Sane in the Age of Agents
kahnwong
0
110
National Coding Day 2026 - Software Evolution: The Complete Lifecycle
kahnwong
0
100
Microsoft Ignite After Party 2025 - Azure Infrastructure for Cloud Native Solutions
kahnwong
0
84
AI Community Day Bangkok 2025 - In-Browser ML/LLM Inference Ecosystem
kahnwong
0
110
Data & AI Day 2025 - You Created a Pipeline, Now What?
kahnwong
0
150
Pycon Thailand 2025 - ML Model Serving Optimization with ONNX
kahnwong
0
96
MFEC x Google Cloud Thailand: Betagro Bootcamp - IaC Adoption
kahnwong
0
100
Other Decks in Technology
See All in Technology
DBTS2026 盛り上がってますか!?Databricksが実現するAI時代のデータ基盤
akuwano
1
200
cdkd (CDK Direct)
gotok365
4
300
複数システムが同居した 15 年物の AWS アカウントを解体するための考古学
wa6sn
3
140
仕様と現実の間で落とし所を探るリモートMCPの認証・認可 — Sansanの認証基盤における課題と実践
sansantech
PRO
2
280
セキュリティ専任チームなしで攻撃を先回りするSREが実践したSIEM on Amazon OpenSearch Service
cscengineer
PRO
1
850
田んぼの見回りをIoTで減らしたい!水位監視から電池駆動カメラまでの試行錯誤
itosoft
1
120
MCPでAIが自分で調べに行く
cdataj
0
170
アラートを見直していたら営業組織への理解にちょっとだけ繋がった話
z63d
1
180
AIが会計業務の伴走者に。 マネーフォワード クラウド会計MCPサーバーで実現するAI前提の新しい業務プロセス
nobitabashi
0
110
Biohub - Cell Tracking During Development 5th place solution
rist
0
140
少ない人手 限られた予算 それでも守る 消せない・見つける・戻れる オールハザード型BCP on AWS / 20261107 Mitsutoshi Matsuo
shift_evolve
PRO
0
370
思考過程から秘密が漏れる:Amazon Bedrock上のKimi K3を5つの方法で攻めたら、25回中22回漏洩した話
yama3133
1
150
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
560
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.2k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
60k
Producing Creativity
orderedlist
PRO
348
41k
Darren the Foodie - Storyboard
khoart
PRO
5
4.1k
Bash Introduction
62gerente
615
220k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
470
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
480
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
We Have a Design System, Now What?
morganepeng
55
8.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k