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
从零开始,打造 Ruby 项目的容器化集成工具
Search
Ivan Chou
September 19, 2017
Programming
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
从零开始,打造 Ruby 项目的容器化集成工具
Ivan Chou
September 19, 2017
Other Decks in Programming
See All in Programming
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
110
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
霧の中の代数的エフェクト
funnyycat
1
280
Contextとはなにか
chiroruxx
1
390
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
1.6k
dRuby over BLE
makicamel
2
410
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
4.8k
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
180
自作OSでスライド発表する
uyuki234
1
3.7k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.3k
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
330
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
400
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
500
Producing Creativity
orderedlist
PRO
348
40k
Why Our Code Smells
bkeepers
PRO
340
58k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
270
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
30 Presentation Tips
portentint
PRO
1
340
4 Signs Your Business is Dying
shpigford
187
22k
Transcript
从零开始 为 Ruby 项⽬目容器器化打造集成⼯工具
⽤用 docker 来部署 Rails 项⽬目 这个有什什么好讲的?
Rubyist 周艺 铲屎官 曾就职于「速递易易」 现在在「知⼈人」in「彩程」 @IChou 沉浸在 Review 中的「⼀一只猫2」
全国最⼤大的智能快递柜公司 ⾄至少…暂时…应该是
快递柜01 快递柜02 快递柜03 快递柜04 快递柜05 快递柜06 快递柜6w …… Business Center
(Rails) Sidekiq Queue01 Queue02 Queue03 Queue04 Queue05 Queue14 …… RubyApp01 RubyApp02 RubyApp03 RubyApp04 RubyAppX …… OtherApp 若⼲干 ⾃自建DDOS ⽆无脑 Retry
上线⼀一不不⼩小⼼心就 解锁了了成就 不不过没关系 反正都是「阿⾥里里云的锅」
Microservices 应⽤用数量量爆炸、请求链路路复杂、雪崩⻛风险 Capistrano 服务器器资源分配不不均、回滚不不总是可靠、单次部署数量量受限 OneAPM ⼀一个⽉月总有那么⼏几天报警有问题或者不不及时 Staff 只有⼀一名运维⼯工程师
▸ 榨⼲干服务器器资源,控制⽀支出(主要原因) ▸ 秒级扩容 ▸ 真正实时的监控和告警 ▸ 快速可靠的回滚 ▸ 熔断机制
▸ 简化运维操作(图形化产品) 亟待解决的问题:
None
搞事情~ 搞事情~ ⼀一个实习⼀一对基 吴天亮 速递易易第⼀一运维 ⾦金金海海洋 娶了了成都妹⼉儿的江苏⼈人 胡鸿达 基础平台⽼老老⼤大
GoCD https://www.gocd.org Open source continuous delivery server to model and
visualize complex workflows with ease
Rancher an open source project that provides a complete platform
for operating Docker in production https://github.com/rancher/rancher
GoCD Rancher IMAGE How to build? How to deploy?
docker_compose https://github.com/docker/compose discourse_docker https://github.com/discourse/discourse_docker
base_image ubuntu_image GoCD Ruby APP + work_image Docker Registry Rancher
build deploy Rancher cli discourse_docker
OpenResty Kafka Kibana Ruby APP Rancher balancer work_image 钉钉机器⼈
理理想中 事实上
▸ 部署更更慢了了(20min 以上很正常) ▸ 配置更更复杂了了 ▸ 迁移进度慢、成本⾼高 ▸ 不不稳定因素增加了了 容器器化带来的新问题
来,我们商量量个事⼉儿 不不难吧 相信你 ⼀一周可以搞定么? 你抽点时间把容器器化这块重构了了
因地制宜 1 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 重新设计镜像,规划打包流程
base_image ubuntu_image Ruby APP + work_image 10 mins at least
ruby:2.3.1 base_image Gemfile + App_base_image Ruby APP + work_image about 30sec install deps & bundle Before After
100 200 300 400 500 600 700 800 900 (MB)
Before After 镜像减肥 镜像设计的核⼼心思想:是简,不不是⼩小
Base_Image 打包内容⼀一览 ▸ 本地化 (语⾔言、时区、apt 源、gem 源) ▸ 必需的依赖 (libmysqlclient-dev
etc.) ▸ 被认为必要的⼯工具 (sudo curl cron vim htop runit nscd) ▸ OpenResty ▸ live 账户初始化 ▸ pups
⼀一劳永逸 2 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 功能模块化,建项⽬目如搭积⽊木
PUPS Simple yaml based bootstrapper for Linux machines https://github.com/SamSaffron/pups Powered
by Ruby
web.puma.template.yml Merge yaml files Run shell command Create/replace files Hook
support Params
container.yml templates
docker run templates content of all templates pups content run
cmd docker commit docker tag PUPS from base_image push image 这是个⿊黑箱镜像啊~ 镜像打包⼯工具 packer
None
Template 编写原则 ▸ Convention Over Configuration ▸ DRY ▸ Flexible
enough
化繁为简 3 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 配置要够简单,也要够灵活
之前的配置⽂文件 container.yml rancher-compose.yml docker-compose.yml X 2 X 40 = 240
之前的部署命令
⽬目标:⼀一个⽉月内完成 20+ 项⽬目的容器器化迁移 限定:不不能影响新需求开发进度,⾃自⼰己抽时间
镜像部署⼯工具 deployer container.yml rancher-compose.yml docker-compose.yml path/to/deployer #{PROJECT_NAME} production $GO_PIPELINE_LABEL
So easy! ⼀一个⽉月 “所有”⽼老老项⽬目全部迁移到容器器
runit + entrypoint.sh etc/ !"" runit/ # !"" 1.d #
# %"" 00-commands-for-launch # %"" 3.d # %"" 01-commands-for-halt !"" service/ # !"" cron # # !"" run # # %"" supervise # !"" nginx -> /etc/service-available/nginx # !"" nscd # # !"" run # # %"" supervise # %"" puma -> /etc/service-available/puma %"" service-available/ !"" nginx # !"" run # %"" supervise %"" puma !"" run %"" supervise
授⼈人以⻥鱼 4 Maybe you think this is the translation of
the title, but it’s not. hahaha ~ 管理理界⾯面化,降低使⽤用成本
配置管理理界⾯面化 ▸ 偷懒 ▸ 新功能快速推⾏行行 ▸ 可复⽤用的系统 ▸ 权限控制
ROCKETS BASE IMAGE PACKER DEPLOYER ? WEB
总结 5 因地制宜 注重⾃自身特点,设计镜像层次及打包流程 ⼀一劳永逸 打包流程按功能模块化,建项⽬目如搭积⽊木 化繁为简 配置要尽可能简单,避免低效的重复劳动 授⼈人以⻥鱼 简单易易⽤用,体验友好,才是⼀一款合格的⼯工具
懒
反思
搅基或内推 请关注
谢谢⼤大家 祝各位码运昌隆隆