Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Running Laravel on Amazon ECS (2021)

2f42f32689c8244280dd01d864f92079?s=47 Ernest Chiang
September 24, 2021

Running Laravel on Amazon ECS (2021)

This is the presentation deck of the talk given on 2021-09-23 at the meetup of AWSUG Taiwan. Thanks for the invitation of AWSUG Taiwan.

You can find the meetup video recording in Chinese at https://youtu.be/ge3O_4KLIzg?t=3473

`dwchiang/nginx-php-fpm` Docker image project for PHP developers:
https://hub.docker.com/r/dwchiang/nginx-php-fpm

Ernest's study notes on Amazon ECS:
https://www.ernestchiang.com/en/notes/aws/ecs/

Ernest's blog:
https://www.ernestchiang.com/

2f42f32689c8244280dd01d864f92079?s=128

Ernest Chiang

September 24, 2021
Tweet

Transcript

  1. Ernest Chiang, 2021 拆解整合 將 Laravel 運⾏在 Amazon ECS Running

    Laravel on Amazon ECS
  2. Shared Notes • https://hackmd.io/@dwchiang/ laravel-on-amazon-ecs-2021- awsug • 短網址:
 https://bit.ly/ecs2021awsug •

    問與答 Q&A 共筆筆記
  3. 拆.解.整.合.的.旅.⼈ • PAFERS
 Product & Technology Integration • AWS
 Community

    Hero • ex-TSMC
 Process Integration Engineer Ernest Chiang
  4. COSCUP | https://bit.ly/yt-pkb 近期分享

  5. Outline ⼤綱 • 拆解整合;思路介紹 • Laravel • Virtualization; Containerization; Orchestration

    • Amazon ECS • Laravel on Amazon ECS • Demo
  6. 資訊爆炸?無法消化? www.ErnestChiang.com 思路

  7. 藉由拆解、定義,釐清思緒。 1

  8. 藉由拆解、定義,釐清思緒。 再⽤整合、組合,實現產出。 1

  9. 藉由拆解、定義,釐清思緒。 再⽤整合、組合,實現產出。 1

  10. None
  11. 先⼿動,再⾃動。 2

  12. 就。很。動。 2

  13. 1. 草稿初版流程。 2

  14. 1. 草稿初版流程。 2. 驗證流程產出。 2

  15. 1. 草稿初版流程。 2. 驗證流程產出。 3. 找⼯具⾃動化。 2

  16. 流程步驟 2

  17. S. + V. + O. 流程步驟 2

  18. input/trigger (S.) 👉 process (V.) 👉 output (O.) 流程步驟 2

  19. input/trigger (S.) 👉 process (V.) 👉 output (O.) 流程步驟 2

  20. input/trigger (S.) 👉 process (V.) 👉 output (O.) ⾃動化 2

  21. 先⼿動,再⾃動。 2

  22. None
  23. Class vs. Instance 3

  24. 3

  25. 3

  26. 3

  27. 3

  28. 3

  29. Class vs. Instance 3

  30. img src: https://commons.wikimedia.org/wiki/File:Cair_Pavarel.jpg Laravel www.ErnestChiang.com issues?

  31. That is Cair Paravel, the castle of the four thrones.

  32. 從 本機 開始

  33. 先⼿動,再⾃動。

  34. 我 👉 開發 👉 程式源碼 www.ErnestChiang.com

  35. 我 👉 安裝 👉 執⾏環境 www.ErnestChiang.com

  36. 我 👉 安裝 👉 作業系統 www.ErnestChiang.com

  37. 我 👉 安裝 👉 ⼀台電腦 www.ErnestChiang.com

  38. 我 👉 安裝 👉 ⼀台電腦 我 👉 安裝 👉 作業系統

    我 👉 安裝 👉 執⾏環境 我 👉 開發 👉 程式源碼 www.ErnestChiang.com
  39. 我 👉 安裝 👉 ⼀台電腦 👈 別⼈做的 我 👉 安裝

    👉 作業系統 👈 別⼈做的 我 👉 安裝 👉 執⾏環境 👈 別⼈做的 我 👉 開發 👉 程式源碼 👈 ⾃⼰做的 www.ErnestChiang.com
  40. 我 👉 安裝 👉 ⼀台電腦 我 👉 安裝 👉 作業系統

    我 👉 安裝 👉 執⾏環境 我 👉 開發 👉 程式源碼 www.ErnestChiang.com
  41. 在我的電腦上,可以正常執⾏ www.ErnestChiang.com

  42. 在同事電腦上,就。很。炸。 www.ErnestChiang.com

  43. 就別提部署到量產主機了?!

  44. www.ErnestChiang.com

  45. www.ErnestChiang.com

  46. 所以?將 PHP Code 打包?

  47. 還是 加上 執⾏環境 ⼀起打包?

  48. 還是 外加 作業系統 ⼀起打包?

  49. 好,⾄少我們知道這台電腦不能打包。

  50. 就。不。包。

  51. solution? Virtualization www.ErnestChiang.com

  52. Virtualization 虛擬化 • Virtual • Virtual machine (VM) • Hypervisor

    • Guest OS • Virtual machine monitor (VMM) • KVM • Hyper-V • Xen • VirtualBox • QEMU • Docker • Amazon ECS • Kubernetes • OpenShift
  53. Virtualization 虛擬化 • Virtual • Virtual machine (VM) • Hypervisor

    • Guest OS • Virtual machine monitor (VMM) • KVM • Hyper-V • Xen • VirtualBox • QEMU • Docker • Amazon ECS • Kubernetes • OpenShift
  54. Virtualization 虛擬化 • Virtual • Virtual machine (VM) • Hypervisor

    • Guest OS • Virtual machine monitor (VMM) • KVM • Hyper-V • Xen • VirtualBox • QEMU • Docker • Amazon ECS • Kubernetes • OpenShift
  55. Creating a virtual version of something;

  56. Creating a virtual version of something;

  57. A hypervisor (or virtual machine monitor, VMM, virtualizer) is computer

    software, firmware or hardware that creates and runs virtual machines.
  58. www.ErnestChiang.com

  59. www.ErnestChiang.com

  60. img src: https://unsplash.com/photos/CJdZ800-Fbs part of virtualization Containerization www.ErnestChiang.com

  61. Operating-system-level virtualization, also known as containerization, refers to an operating

    system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances, called containers, partitions, virtual environments (VEs) or jails (FreeBSD jail or chroot jail), may look like real computers from the point of view of programs running in them.
  62. Operating-system-level virtualization, also known as containerization, refers to an operating

    system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances, called containers, partitions, virtual environments (VEs) or jails (FreeBSD jail or chroot jail), may look like real computers from the point of view of programs running in them.
  63. Operating-system-level virtualization, also known as containerization, refers to an operating

    system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances, called containers, partitions, virtual environments (VEs) or jails (FreeBSD jail or chroot jail), may look like real computers from the point of view of programs running in them.
  64. Operating-system-level virtualization, also known as containerization, refers to an operating

    system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances, called containers, partitions, virtual environments (VEs) or jails (FreeBSD jail or chroot jail), may look like real computers from the point of view of programs running in them.
  65. www.ErnestChiang.com

  66. www.ErnestChiang.com

  67. www.ErnestChiang.com

  68. www.ErnestChiang.com

  69. www.ErnestChiang.com

  70. www.ErnestChiang.com

  71. www.ErnestChiang.com

  72. www.ErnestChiang.com

  73. > php artisan migrate www.ErnestChiang.com

  74. www.ErnestChiang.com

  75. www.ErnestChiang.com

  76. www.ErnestChiang.com

  77. www.ErnestChiang.com

  78. www.ErnestChiang.com

  79. www.ErnestChiang.com

  80. www.ErnestChiang.com

  81. www.ErnestChiang.com

  82. www.ErnestChiang.com

  83. www.ErnestChiang.com

  84. None
  85. www.ErnestChiang.com

  86. www.ErnestChiang.com

  87. Virtualization 虛擬化 • Virtual • Virtual machine (VM) • Hypervisor

    • Guest OS • Virtual machine monitor (VMM) • KVM • Hyper-V • Xen • VirtualBox • QEMU • Docker • Amazon ECS • Kubernetes • OpenShift
  88. Virtualization 虛擬化 • Virtual • Virtual machine (VM) • Hypervisor

    • Guest OS • Virtual machine monitor (VMM) • KVM • Hyper-V • Xen • VirtualBox • QEMU • Docker • Amazon ECS • Kubernetes • OpenShift
  89. Virtualization 虛擬化 • Virtual • Virtual machine (VM) • Hypervisor

    • Guest OS • Virtual machine monitor (VMM) • KVM • Hyper-V • Xen • VirtualBox • QEMU • Docker • Amazon ECS • Kubernetes • OpenShift
  90. Virtualization ├── Hardware-Hypervisors │ ├── Type 1-Native │ │ └──

    KVM, Hyper-V, QNX, VMware vSphere, Xen │ └── Type 2-Hosted │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion └── OperatingSystem ├── 1-OS Containers │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo ├── 2-Application Containers │ └── Docker, imctfy, rkt └── Orchestration └── Amazon ECS, Kubernetes, OpenShift www.ErnestChiang.com
  91. Virtualization ├── Hardware-Hypervisors │ ├── Type 1-Native │ │ └──

    KVM, Hyper-V, QNX, VMware vSphere, Xen │ └── Type 2-Hosted │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion └── OperatingSystem ├── 1-OS Containers │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo ├── 2-Application Containers │ └── Docker, imctfy, rkt └── Orchestration └── Amazon ECS, Kubernetes, OpenShift www.ErnestChiang.com
  92. Virtualization ├── Hardware-Hypervisors │ ├── Type 1-Native │ │ └──

    KVM, Hyper-V, QNX, VMware vSphere, Xen │ └── Type 2-Hosted │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion └── OperatingSystem ├── 1-OS Containers │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo ├── 2-Application Containers │ └── Docker, imctfy, rkt └── Orchestration └── Amazon ECS, Kubernetes, OpenShift www.ErnestChiang.com
  93. Virtualization ├── Hardware-Hypervisors │ ├── Type 1-Native │ │ └──

    KVM, Hyper-V, QNX, VMware vSphere, Xen │ └── Type 2-Hosted │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion └── OperatingSystem ├── 1-OS Containers │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo ├── 2-Application Containers │ └── Docker, imctfy, rkt └── Orchestration └── Amazon ECS, Kubernetes, OpenShift www.ErnestChiang.com
  94. img src: https://unsplash.com/photos/aEnH4hJ_Mrs arrangement Orchestration www.ErnestChiang.com

  95. None
  96. www.ErnestChiang.com

  97. www.ErnestChiang.com

  98. 2 1 1 2

  99. www.ErnestChiang.com

  100. 2 1 1 2

  101. None
  102. 1 2 www.ErnestChiang.com

  103. img src: Photo by sergio souza on Unsplash orchestration Amazon

    ECS www.ErnestChiang.com
  104. www.ErnestChiang.com

  105. 1 2

  106. 1 2 1 2

  107. None
  108. www.ErnestChiang.com

  109. www.ErnestChiang.com

  110. www.ErnestChiang.com

  111. www.ErnestChiang.com

  112. www.ErnestChiang.com

  113. www.ErnestChiang.com

  114. None
  115. www.ErnestChiang.com

  116. www.ErnestChiang.com

  117. img src: Photo by sergio souza on Unsplash on Amazon

    ECS Running Laravel www.ErnestChiang.com
  118. www.ErnestChiang.com

  119. www.ErnestChiang.com

  120. www.ErnestChiang.com

  121. None
  122. www.ErnestChiang.com ECR

  123. S. (I) V. O. (image) ECR www.ErnestChiang.com

  124. S. (ECS) V. O. ECR www.ErnestChiang.com

  125. S. (CI) V. O. CI www.ErnestChiang.com

  126. www.ErnestChiang.com

  127. www.ErnestChiang.com Search "ernest laravel ecs workshop" to download.

  128. www.ErnestChiang.com Search "ernest laravel ecs workshop" to download.

  129. Demo www.ErnestChiang.com never live demo!

  130. 參考資料 www.ErnestChiang.com Reference

  131. 參考資料 Virtualization • Wikipedia - Virtualization • https://en.wikipedia.org/wiki/Virtualization • Playing

    With Firecracker VMM at COSCUP 2020 • https://www.ernestchiang.com/en/posts/2020/playing-with- fi recracker/ • Firecracker • https:// fi recracker-microvm.github.io/
  132. 參考資料 Virtualization • Linux 核⼼設計_發展動態回顧 • https://www.youtube.com/watch?v=-2Pn4B8S1EM • Embedded Virtualization

    applied in Mobile Devices • https://www.slideshare.net/jserv/mobile-virtualization
  133. 參考資料 Containerization • Wikipedia - OS-level virtualization • https://en.wikipedia.org/wiki/OS-level_virtualization

  134. 參考資料 Orchestration • Docker image of nginx + php-fpm (amd64/arm64)

    • https://hub.docker.com/r/dwchiang/nginx-php-fpm
  135. 參考資料 Amazon ECS • My study notes • https://www.ernestchiang.com/en/notes/aws/ecs/ •

    Nathan Peck's Awesome List • https://github.com/nathanpeck/awesome-ecs • 技術選型: Amazon ECS Launch Types: EC2 vs. Fargate • https://www.ernestchiang.com/zh/posts/2020/technology-selection-amazon-ecs-launch- type/ • 5 Steps: Using Amazon ECS Exec to pass through Fargate/ECS into containers • https://www.ernestchiang.com/en/posts/2021/using-amazon-ecs-exec/
  136. 參考資料 Running Laravel on Amazon ECS • Workshops: Running Laravel

    on AWS ECS (using CDK) • https://github.com/dwchiang/laravel-on-aws-ecs-workshops • CDK Construct Hub • https://constructs.dev/ • CDK patterns for modern application with serverless containers on AWS • https://github.com/aws-samples/serverless-container-constructs • My study notes on CDK • https://www.ernestchiang.com/en/notes/aws/cdk/
  137. Virtualization software

  138. Search "ernest aws ecs" to download.

  139. Ernest's Blog • https://www.ernestchiang.com 拆 / 解 / 整 /

  140. Ernest's Newsletter • https://bit.ly/3B2ksae 拆 / 解 / 整 /

    合 電⼦報
  141. 問與答 www.ErnestChiang.com 更多對話

  142. Shared Notes • https://hackmd.io/@dwchiang/ laravel-on-amazon-ecs-2021- awsug • 短網址:
 https://bit.ly/ecs2021awsug •

    問與答 Q&A 共筆筆記