Slide 1

Slide 1 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 今⽇のテーマ 難しい事抜きでまずはアプリケーションを コンテナ化してみよう !

Slide 2

Slide 2 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 本⽇の参加メンバー

Slide 3

Slide 3 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. “既存のアプリケーションを コンテナ化します” ! どこから⼿をつけますか︖

Slide 4

Slide 4 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. コンテナへの移⾏⼿順 既存のアプリケーションが動く環境の把握 コンテナで動かすことを想定したリファクタリング コンテナイメージの作成 ビジネスゴールの評価 組織編成 プラットフォーム選定 概念実証 (PoC) 運⽤ ガバナンス

Slide 5

Slide 5 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. (難しいこと抜きにした) コンテナへの移⾏⼿順 既存のアプリケーションが動く環境の把握 コンテナで動かすことを想定したリファクタリング コンテナイメージの作成

Slide 6

Slide 6 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. サンプルアプリケーション: ⽂章翻訳サービス AWS Cloud アプリケーション (Java / Tomcat) データベース (MySQL) Amazon Translate 1. ⽂書取得 2. ⽂書翻訳 3. 翻訳⽂書保存

Slide 7

Slide 7 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. サンプルアプリケーション: ⽂章翻訳サービス デモをお⾒せします

Slide 8

Slide 8 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 既存のアプリケーションが動く環境の把握 コンテナで動かすことを想定したリファクタリング コンテナイメージの作成

Slide 9

Slide 9 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションサーバーには何が必要︖ !

Slide 10

Slide 10 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 例: サンプルアプリケーションの場合 • アプリケーションコード • アプリが依存している 3rd party ライブラリ => WAR ファイルを本番環境 (EC2 インスタンス) にデプロイ • (アプリケーションコードの) ランタイム => 本番環境 (EC2 インスタンス) のプロビジョニング時に Java と Tomcat をインストール

Slide 11

Slide 11 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 既存のアプリケーションが動く環境の把握 コンテナで動かすことを想定したリファクタリング コンテナイメージの作成

Slide 12

Slide 12 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. コンテナ化に伴いリファクタリングは必要︖ !

Slide 13

Slide 13 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. アプリケーションに可搬性がない場合... OS ライブラリ コンテナイメージ 開発⽤ アプリケーション 開発環境 本番環境 開発⽤ アプリケーション AWS Cloud9 Amazon ECS ※ Amazon ECS: Amazon Elastic Container Service

Slide 14

Slide 14 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. The Twelve-Factor App The Twelve-Factor App (⽇本語訳) https://12factor.net/ja/

Slide 15

Slide 15 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 例: サンプルアプリケーションの場合 ローカルマシンで実⾏されるインメモリデータベースにデータを保存 => バックエンドサービスとしてデータベースを切り離す 🙅 ローカルマシンのメモリ上にセッション情報を保存 => セッション情報を外部ストレージに保存する 🙅 アプリケーションログをファイルに出⼒ => ログを標準出⼒にイベントストリームとして出⼒ 🙅 IV. バックエンドサービス VI. プロセス XI. ログ : The Twelve-Factor App プラクティス

Slide 16

Slide 16 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 既存のアプリケーションが動く環境の把握 コンテナで動かすことを想定したリファクタリング コンテナイメージの作成

Slide 17

Slide 17 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. どうやってコンテナイメージを作成する︖ !

Slide 18

Slide 18 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dockerfile を利⽤したコンテナイメージの作成 # WAR ファイルを Gradle 公式イメージの中でビルド FROM public.ecr.aws/docker/library/gradle:7.5.1-jdk17 as builder COPY ./ /home/gradle/ RUN gradle --no-daemon war # WAR ファイルを Tomcat 10 のイメージにコピー FROM public.ecr.aws/docker/library/tomcat:10.1.11-jre17 COPY --from=builder /home/gradle/build/libs/docrdr.war $CATALINA_HOME/webapps/ROOT.war # このアプリケーションが公開するポート EXPOSE 8080 例: サンプルアプリケーションの場合

Slide 19

Slide 19 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 参考資料: コンテナ化のためのリアーキテクチャ Re-Architecture for Containers https://catalog.us-east-1.prod.workshops.aws/workshops/a49e50ba-7473-4348-ba5d-6166385ad91d/ja-JP