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
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
210
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
180
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
130
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
1
110
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
350
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
160
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
520
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
460
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
390
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
630
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
450
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1.1k
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
1k
Mind Mapping
helmedeiros
PRO
1
290
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
We Have a Design System, Now What?
morganepeng
55
8.2k
Navigating Weather and Climate Data
rabernat
0
440
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Unsuck your backbone
ammeep
672
58k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
190
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.7k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
360
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 因地制宜 注重⾃自身特点,设计镜像层次及打包流程 ⼀一劳永逸 打包流程按功能模块化,建项⽬目如搭积⽊木 化繁为简 配置要尽可能简单,避免低效的重复劳动 授⼈人以⻥鱼 简单易易⽤用,体验友好,才是⼀一款合格的⼯工具
懒
反思
搅基或内推 请关注
谢谢⼤大家 祝各位码运昌隆隆