heroku でカンタンすぐに実現する ci/cd

34
Heroku でカンタンすぐに実現する CI/CD Open Developers Conference 2017 TOKYO [email protected] @sho7650 阿部 崇 (Takashi Abe) Platform Specialist@株式会社セールスフォース・ドットコム

Upload: takashi-abe

Post on 21-Jan-2018

723 views

Category:

Technology


0 download

TRANSCRIPT

Heroku でカンタンすぐに実現する CI/CDOpen Developers Conference 2017 TOKYO

[email protected]@sho7650

阿部 崇 (Takashi Abe) Platform Specialist@株式会社セールスフォース・ドットコム

Forward-Looking Statements

Statement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.comproducts, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

本⽇のお話の内容

内容• 継続的デリバリーの流れ(継続的インテグレーション・デプロイ)のおさらい• 今⼀度、Heroku を理解する• Heroku と Githubで、CI/CD がカンタンに実現できる様に驚愕する

対象者

• アプリケーション開発者• ターミナルでコマンド操作ができる⼈• Github を使えている⼈• Heroku を使ってみたい・使っている⼈• Salesforce が好きな⼈• しょっさんが好きな⼈

ゴール • Heroku のアカウントを作成して、Heroku へアプリをデプロイする• Heroku CI と Heroku Pipelines を設定して、フローを回すことができる

⾃⼰紹介Heroku Webinar 担当

今日の解説者

阿 部 崇 (Takashi Abe)Platform Specialist (@sho7650)

アプリエンジニア à HWエンジニア à インフラエンジニアà アーキテクト兼ITコンサル à 現職

ライブと熱帯魚が好き: Perfume/BABYMETAL/藤原さくら/稲川淳二

Heroku 概要 (復習)“作る”と”動かす”両⽅に効くクラウドサービス

Webアプリの開発・運用(安定稼働)には悩みも多い

アプリ開発者 アプリ利⽤者アプリ

(本番稼働中)アプリ

(開発中)

• ちゃんと動いているか、OS/ミドルウエア/アプリそれぞれ監視しないといけないよね…

• ミドルウェアにセキュリティホールが⾒つかった?早くパッチ当てなきゃ…

• アプリで使うライブラリやソフトウェアなどミドルウェアを準備するの⾯倒だ…

• 本番環境の他に、ステージング環境とか開発環境とか構築しないといけないよね…

継続的な機能追加・改修・デプロイ

これらを”うまく”まわす仕組みを⾃前で構築・運⽤管理していくのは⼤変“作る”と”動かす”両⽅に効く Heroku の特徴を「信頼性」「拡張性」 「開発⽣産性」の3つの観点で解説

【動かす:信頼性】アプリ実⾏基盤は Heroku が管理・運⽤

ミドルウェア

DBMS

OS

仮想化

サーバー

ストレージ

ネットワーク

施設

アプリケーション

オンプレミス

アプリケーション

ミドルウェア

DBMS

OS

仮想化

サーバー

ストレージ

ネットワーク

施設

IaaS(Infrastructure as a Service)

アプリケーション

ミドルウェア

DBMS

OS

仮想化

サーバー

ストレージ

ネットワーク

施設

SaaS(Software as a Service)

アプリ開発/サービス提供者管理

クラウドベンダー管理凡例

アプリケーション

ミドルウェア

DBMS

OS

仮想化

サーバー

ストレージ

ネットワーク

施設

PaaS(Platform as a Service)

① 24時間/365⽇のグローバルな運⽤体制

② ⼤規模インフラ運⽤の豊富なナレッジ蓄積

③ 規模の原理を活かした対応・対策への投資

④ 稼働実績の公開

他クラウドベンダーのIaaSを利⽤

【動かす:拡張性】開発アプリのキャパシティを容易に拡張できる

構成要素 説明 拡張⽅法

Dyno 作成したプログラムを動かすコンテナ

平⾏稼働するDynoの数を増やす

Data データを管理・保管する領域

より⼤容量・⾼性能なプランにデータを移し切り替える

Add-ons 便利な追加機能群 クリックやコマンドで機能を追加し環境変数を設定する

PaymentsEmailSMSSearchAnalyticsMonitoringLogging

RubyNode.jsJavaNode.jsNode.jsScalaClojure

PostgresRedisKafka

まず理解する Heroku の構成要素と拡張の仕⽅

そんな簡単に拡張できるものなの?

これらのコンセプトに即し設計開発されたアプリなら

The Twelve Factor App

マイクロサービス

【作る:開発⽣産性】継続的な開発→デプロイの実⾏に役⽴つ機能を提供

項⽬ 説明

バージョン管理 • Git / Githubとの強⼒な連携・統合

品質を⾼める開発プロセス準拠

• Pipeline機能によりレビュー > ステージング > 本番 それぞれの環境をスムーズに移⾏

環境複製 • Forkコマンドで、稼働環境のクローンを容易に作成

エンタープライズ⽤途にも対応できる機能/サービスを提供

項⽬ 説明

Private Spaces • DynoやDataなど、Herokuのアプリ実⾏環境をネットワーク的に分離された環境に構築

• ⽇本国内のデータセンター利⽤も可能

エンタープライズサポート

• 技術的な質問やトラブル時のサポートチケットに対して、重要度に応じた応答時間のSLAを提供

• ⽇本語でのサポート対応を提供• 導⼊時のアーキテクチャデザインやAdd-on選定といった

ご相談に⽇本⼈技術者が対応

Heroku Connect • Salesforceのオブジェクトとの双⽅向データ同期機能を提供

Private Spaces

Heroku Connect

PostgresHeroku

オブジェクトSalesforce

アプリケーションの開発・デプロイには悩みが多い

アプリ開発者 アプリ利⽤者

開発

• アジャイルだからって、毎⽇、ソースコードをコミットする度に、コンパイルしてユニットテストを⼿で回すなんて、現実的じゃない...

• デプロイする環境はあるかな...

• ウォーターフォールなので、テストも、開発フェーズじゃユニットテストしかやらないから、ほんとに動くのかどうか、数ヶ⽉後じゃないとわからない...

• エクセルにテスト結果貼らなきゃ...

これらを”うまく”まわす仕組みを⾃前で構築・管理していくのは⼤変ビルド (コンパイルàテストàリリース) & デプロイを断続的・継続的に実現することが必要不可⽋

ビルド テスト リリース

継続的な機能追加・改修・テスト・デプロイが求められてるが...

デプロイ

これらを解決していくには...?

Continuous Model継続モデル継続的〜を理解して、俊敏性の⾼い開発モデルを実現

実現する範囲によって、継続的〜の実現要素が変わる継続的〜はいろいろあるが、結局何か

Code開発

Buildビルド

Testテスト

Releaseリリース

Deployデプロイ

Operate運⽤

アジャイル開発

継続的インテグレーション

継続的デリバリー

継続的デプロイメント

DevOps

Continuous Integration継続的インテグレーション「動作する」ソフトウェアを短期間に開発

継続的インテグレーション(CI)は何か動作するソフトウェアを短期間に開発したい

開発

ビルドテスト

継続的インテグレーションの⽬的ソフトウェア開発の「リスクを削減」する

17 | ©2017 Salesforce

1 リスクを軽減する

2 繰り返しが多い手作業の削減

3 デプロイ可能なソフトウェア

4 プロジェクトの見える化

5 開発チームの自信を深める

出典: 「継続的インテグレーション入門」日経BP社

Continuous Delivery継続的デリバリー動作するソフトウェアを、いつでもリリース可能

継続的デリバリー(CD)は何か開発されたソフトウェアを、常にデプロイできる状態を保つ

開発

ビルド

テスト

リリース

継続的デリバリーの⽬的開発中のソフトウェアを、いつでもデプロイできる状態にすること

20 | ©2017 Salesforce

“The key test is that a business sponsor could request that the current development version of the software can be deployed into production at a moment's notice”

– Martin Fowler (https://martinfowler.com/bliki/ContinuousDelivery.html )

「今、開発中のバージョンを、すぐに本番環境にデプロイしろ」という、お客様からのリクエストに対処できるか

参考(Deployment Pipeline) http://martinfowler.com/bliki/DeploymentPipeline.html

Continuous Deployment継続的デプロイ利⽤可能なソフトウェアを、常にリリース&デプロイ

継続的デプロイ(CD)とは何かソフトウェアを、いつでも、どこでも、最⼩限の労⼒でリリース

開発

ビルド

テストリリース

デプロイ

継続的デプロイの⽬的と7つの重要なポイントソフトウェアの変化を最速で提供し、企業価値を創出

23 | ©2017 Salesforce

1 動作するソフトウェアを常にリリース & デプロイ

2 リポジトリ資産へラベリング

3 クリーンな環境の構築

4 個々のビルドにラベリング

5 すべてのテストの実⾏

6 ビルドフィードバックレポート

7 ロールバックが可能なこと

出典: 「継続的インテグレーション入門」日経BP社

Heroku CI/CDHeroku が提供する CI/CD の⾃動化機能

CI/CD を実現するための機能を備えたプラットフォームHeroku は、Heroku CI と Heroku Pipelines を組み合わせて、CI/CDを提供

開発

ビルド

テストリリース

デプロイ

GitHub Flow とHeroku は連携しやすい開発スタイルプルリクエストと連動して、アプリ環境を⾃動的に⽣成

Update index.html

Create readmore.md

master

Hammertime

Heroku CI継続的インテグレーションを⽀える、⾃動テスト機能を提供

https://devcenter.heroku.com/articles/heroku-ci

テストの結果をダッシュボードから確認可能!

過去のテスト内容もみられるよ!

Heroku Pipelines継続的デリバリー・デプロイを実現するための便利なワークフロー

https://devcenter.heroku.com/articles/pipelines

プルリクエストと連動してCIを実現!!

デプロイ状況が、画⾯で⼀望できるね

Heroku CI/CD DEMO実際に⾒てみましょう

今回のデモシナリオCodeZine「Herokuとチーム開発のおいしいレシピ」の内容をデモ実演

1 改修⽤のブランチで、ソースコードの改修とプッシュ

2 テストの結果を確認して、プルリクエスト

3 master ブランチへマージ、ステージング環境で確認

4 本番環境へデプロイ!

CodeZine: 「Herokuとチーム開発のおいしいレシピ〜HerokuとGitHubを連携してCI/CDを実現する」 https://codezine.jp/article/detail/10233

デモのおさらい⼿順の確⽴したデプロイパイプラインに従って、安全にリリース & デプロイ

ローカル: リポジトリ

GitHub: リポジトリ

Heroku CI

Heroku: Review Apps

Heroku: STAGING

Heroku: PRODUCTION

git clone

コード改修

git push

⾃動テスト

テスト結果

プルリクエスト

アプリテスト

マージ

テスト完了待ち

⾃動テスト

受⼊テスト

デプロイ!(Promote!!)

Heroku アプリケーション環境

1.改修とプッシュ 2.プルリクエスト 3.master ブランチへマージしてステージング環境でテスト 4.デプロイ

今⽇のまとめ

ITエンジニアの⽴場 • 迅速で、かつ変化に対応できる ITエンジニアが求められる

継続的デリバリー(継続的インテグレーション/デプロイ)

• いつでもソフトウェアをリリースできる流れ• ⾃動ビルド&デプロイにより、継続的デリバリーを実現

Heroku • 開発者による、開発者のためのプラットフォーム

Heroku CI/CD• Heroku Pipelinesで⾃動ビルド&デプロイ• Heroku CI は⾃動テストを実現

Heroku は開発者の皆さまを、様々なしがらみから開放します

次のステップへ...Trailhead

Heroku Enterpriseの基礎

Heroku Enterpriseをいつどのように使⽤するかに

ついての基礎を学習します

SalesforceとHerokuのインテグレーション

HerokuのアプリケーションをSalesforceに統合するためのパターンと⽅法を学びます

https://trailhead.salesforce.com/ja