03 Jun Laravel in Docker on the Cloud – Amazon ECS
We have created our Docker Hub image here and hosted it in a self-provisioned Ubuntu server.
What if we want to host it on Amazon ECS (Elastic Container Service) Fargate with the Docker Hub image?
Let’s do it:
1. Sign in to AWS Console (if you don’t have an account yet, just sign one up, Farget is billed per minute, a test will only cost less than a dollar)
2. Go to Services -> ECS -> Task Definition -> Create new task defination -> Choose Fargate for type
3. When creating the task definition:
Name: Give it your preferred name
Task Role: None
Task Memory: 0.5GB
Task CPU: 0.25
Add Container -> Give the container image a name, e.g. ‘laravel01-dockerhub’ -> Image URL: docker.io/[username]/laravel01:latest
4. Click the create button
5. A Task Definition won’t run without a Cluster, we will proceed to create a ECS Cluster by going back to ECS dashboard -> Cluster -> Create Cluster
6. Choose the first option with the big ‘Powered by AWS Fargate’ Give it a name
7. View Cluster -> Task Tab -> Run New Task:
Launch Type: Fargate
VPC: choose the first one in list (your default VPC)
Subnet: choose the first one in list (one of your default subnet)
Then Click on Run Task button
8. Wait for a few seconds for AWS to provision, pull image, and deploy
9. Once the status changed to RUNNING, its good to go, just check the Public IP in the task detail page, and view it in your browser
This is a quick walkthrough to get a docker image up and running in ECS Fargate, we will explore further how to do updates, creating services, etc. in future.