$30 off During Our Annual Pro Sale. View Details »

AWS Developer Live Show「難しい事抜きでまずはアプリケーションをコンテナ化してみよう」/ Let's try containerizing your application

AWS Developer Live Show「難しい事抜きでまずはアプリケーションをコンテナ化してみよう」/ Let's try containerizing your application

2023 年 9 月 26 日に開催した AWS Developer Live Show「難しい事抜きでまずはアプリケーションをコンテナ化してみよう」の投影資料です。

AWS Developer Live Show のイベントページは、こちらをご参照ください。
https://aws.amazon.com/jp/builders-flash/developer-live-show/

Kyosuke Ochimizu

September 27, 2023
Tweet

More Decks by Kyosuke Ochimizu

Other Decks in Technology

Transcript

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  18. © 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
    例: サンプルアプリケーションの場合

    View Slide

  19. © 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

    View Slide