<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gbenga Oni</title>
    <description>The latest articles on DEV Community by Gbenga Oni (@gbxnga).</description>
    <link>https://dev.to/gbxnga</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F218031%2F8f452768-a691-4781-8fb8-52c83474ee09.jpg</url>
      <title>DEV Community: Gbenga Oni</title>
      <link>https://dev.to/gbxnga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gbxnga"/>
    <language>en</language>
    <item>
      <title>AWS CDK: Deploy Cloud Resources with Typescript</title>
      <dc:creator>Gbenga Oni</dc:creator>
      <pubDate>Fri, 20 Mar 2020 18:50:46 +0000</pubDate>
      <link>https://dev.to/gbxnga/aws-cdk-deploy-cloud-resources-with-typescript-3g9</link>
      <guid>https://dev.to/gbxnga/aws-cdk-deploy-cloud-resources-with-typescript-3g9</guid>
      <description>&lt;p&gt;Have you ever thought of deploying cloud resources with a programming language?&lt;/p&gt;

&lt;p&gt;You know, instead of using Infrastructure as Code tools like Terraform, you use an actual programming language like Typescript, Python or Java to describe resources that will be provisioned in the cloud?&lt;/p&gt;

&lt;p&gt;Great!&lt;/p&gt;

&lt;p&gt;I show you how to do this with Typescript.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://gbengaoni.com/blog/AWS-CDK--Deploy-Cloud-Resources-with-Typescript"&gt;My New blog Post&lt;/a&gt;, I walk you through how to deploy an AWS VPC, Security Group, EC2 instance and an S3 bucket with AWS Cloud Development kit. &lt;/p&gt;

&lt;p&gt;Tip: You can build a SaaS Platform with this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gbengaoni.com/blog/AWS-CDK--Deploy-Cloud-Resources-with-Typescript"&gt;https://gbengaoni.com/blog/AWS-CDK--Deploy-Cloud-Resources-with-Typescript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>aws</category>
      <category>devops</category>
      <category>devrel</category>
    </item>
    <item>
      <title>Kubernetes CI/CD with Helm and Jenkins</title>
      <dc:creator>Gbenga Oni</dc:creator>
      <pubDate>Wed, 18 Mar 2020 17:35:06 +0000</pubDate>
      <link>https://dev.to/gbxnga/kubernetes-ci-cd-with-helm-and-jenkins-14pi</link>
      <guid>https://dev.to/gbxnga/kubernetes-ci-cd-with-helm-and-jenkins-14pi</guid>
      <description>&lt;p&gt;Before I set out to learning Kubernetes some years ago, we had just deployed a government enterprise, monolithic application to Amazon Elastic Container Service. We needed a more flexible, non-provider specific container orchestration tool. Kubernetes looked like the perfect choice. &lt;/p&gt;

&lt;p&gt;Some months into learning Kubernetes, we were ready to move our workload from AWS ECS to Kubernetes.&lt;/p&gt;

&lt;p&gt;One of my biggest challenges was setting up a reliable CI/CD pipeline. &lt;/p&gt;

&lt;p&gt;I decided to write a simplified method we used to achieve that in a blog post. If you are new to Kubernetes and have been wondering how to set up a scalable pipeline to enable seamless integration and deployment of your apps to the Cluster, you will find this useful. &lt;/p&gt;

&lt;p&gt;Here's the &lt;a href="https://awsofthings.com/kubernetes-ci-cd-pipeline-with-helm-and-jenkins/"&gt;blog post&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  AWS # #devops #cloud #kubernetes #cloudnative #devsecops #cicd
&lt;/h1&gt;

</description>
      <category>javascript</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Deploy a Docker-ized Laravel Application to AWS ECS with CodeBuild</title>
      <dc:creator>Gbenga Oni</dc:creator>
      <pubDate>Fri, 06 Mar 2020 11:44:32 +0000</pubDate>
      <link>https://dev.to/gbxnga/deploy-a-docker-ized-laravel-application-to-aws-ecs-with-codebuild-37pi</link>
      <guid>https://dev.to/gbxnga/deploy-a-docker-ized-laravel-application-to-aws-ecs-with-codebuild-37pi</guid>
      <description>&lt;p&gt;Containers have gradually become a wide-spread and widely accepted technology. They are a standard unit of software that encapsulates your code, together with the dependencies required to make them function. With containers, you can be certain your system will function in similar manner even in different environments.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As cloud services have become an integral part of application deployment, the need to effectively build, deploy and maintain containers in the cloud has become imperative.&lt;/p&gt;

&lt;p&gt;There are a number of services designed to help developers achieve this, one of which is &lt;a href="https://aws.amazon.com/ecs/"&gt;AWS Elastic Container Service&lt;/a&gt; — A highly available and high performance container orchestration service. It allows you to run, scale and secure docker containers in AWS.&lt;/p&gt;

&lt;p&gt;In this tutorial, you will learn how to docker-ize a Laravel application. You will also learn how to deploy the image built to EC2 with AWS Elastic Container Service.&lt;/p&gt;

&lt;p&gt;We will use &lt;a href="https://aws.amazon.com/codebuild/"&gt;AWS CodeBuild&lt;/a&gt; — “a fully managed continuous integration service that compiles source code, runs tests, and produces software packages that are ready to deploy” — to build our container image whichwill be stored on &lt;a href="https://aws.amazon.com/ecr/"&gt;AWS Elastic Container Registry(ECR)&lt;/a&gt;, an Amazon managed docker container registry — think Docker hub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A Windows, Linux or Mac PC with Docker installed&lt;/li&gt;
&lt;li&gt;An AWS Account&lt;/li&gt;
&lt;li&gt;Laravel&lt;/li&gt;
&lt;li&gt;A Github Account&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Get Composer
&lt;/h3&gt;

&lt;p&gt;Firstly, we need to download Composer, a PHP package manager. We will use Composer to install Laravel and other dependencies. If you don’t already have it installed, you can &lt;a href="https://getcomposer.org/download/"&gt;download it here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Laravel
&lt;/h2&gt;

&lt;p&gt;Create a fresh Laravel application using composer by running the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer create-project &lt;span class="nt"&gt;--prefer-dist&lt;/span&gt; laravel/laravel laravel-docker-aws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Docker-ize Laravel
&lt;/h2&gt;

&lt;p&gt;Now that we Laravel installed, let's configure docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Dockerfile
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;Dockerfile&lt;/code&gt; in the root of your Laravel application. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; php:7.3.2-apache-stretch&lt;/span&gt;

&lt;span class="k"&gt;LABEL&lt;/span&gt;&lt;span class="s"&gt; maintainer="Gbenga Oni B. &amp;lt;onigbenga@yahoo.ca&amp;gt;" \&lt;/span&gt;
      version="1.0"

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --chown=www-data:www-data . /srv/app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; .docker/vhost.conf /etc/apache2/sites-available/000-default.conf &lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /srv/app&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;docker-php-ext-install mbstring pdo pdo_mysql &lt;span class="se"&gt;\ &lt;/span&gt;
    &amp;amp;&amp;amp; a2enmod rewrite negotiation \
    &amp;amp;&amp;amp; docker-php-ext-install opcache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a docker folder
&lt;/h3&gt;

&lt;p&gt;Lets create a folder where all configuration files needed to build our docker image will be placed. Create a folder &lt;code&gt;.docker&lt;/code&gt; in Laravel root folder that will contain our Apache config file (&lt;code&gt;vhost.conf&lt;/code&gt;). The file will be copied into sites available folder on container at run time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&amp;lt;&lt;span class="n"&gt;VirtualHost&lt;/span&gt; *:&lt;span class="m"&gt;80&lt;/span&gt;&amp;gt;
    &lt;span class="n"&gt;DocumentRoot&lt;/span&gt; /&lt;span class="n"&gt;srv&lt;/span&gt;/&lt;span class="n"&gt;app&lt;/span&gt;/&lt;span class="n"&gt;public&lt;/span&gt;

    &amp;lt;&lt;span class="n"&gt;Directory&lt;/span&gt; &lt;span class="s2"&gt;"/srv/app/public"&lt;/span&gt;&amp;gt;
        &lt;span class="n"&gt;AllowOverride&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt;
        &lt;span class="n"&gt;Require&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="n"&gt;granted&lt;/span&gt;
    &amp;lt;/&lt;span class="n"&gt;Directory&lt;/span&gt;&amp;gt;

    &lt;span class="n"&gt;ErrorLog&lt;/span&gt; ${&lt;span class="n"&gt;APACHE_LOG_DIR&lt;/span&gt;}/&lt;span class="n"&gt;error&lt;/span&gt;.&lt;span class="n"&gt;log&lt;/span&gt;
    &lt;span class="n"&gt;CustomLog&lt;/span&gt; ${&lt;span class="n"&gt;APACHE_LOG_DIR&lt;/span&gt;}/&lt;span class="n"&gt;access&lt;/span&gt;.&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="n"&gt;combined&lt;/span&gt;
&amp;lt;/&lt;span class="n"&gt;VirtualHost&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;vhost.conf&lt;/code&gt; file sets the document root for Apache to &lt;code&gt;/src/app/public&lt;/code&gt;, this way since our Laravel app will be copied to the &lt;code&gt;/srv/app&lt;/code&gt; folder, we can access it directly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build Laravel Application Image locally
&lt;/h3&gt;

&lt;p&gt;Once you’ve created the &lt;code&gt;Dockerfile&lt;/code&gt; and the Apache configuration file in the &lt;code&gt;.docker&lt;/code&gt; folder. Our application is now ready to be built.&lt;br&gt;
Navigate to the root folder of the Laravel app in the command line then run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; laravel-docker-aws &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The docker machine will now build the image. This may take some minutes.&lt;br&gt;
Now that the &lt;code&gt;laravel-docker-aws&lt;/code&gt; image has been built, run the image with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8001:80 laravel-docker-aws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container will now run with accessibility on port 8001:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--85NbJF3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3840/1%2AUekpdzPsocdwt1ZGSNS4YA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--85NbJF3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3840/1%2AUekpdzPsocdwt1ZGSNS4YA.png" alt="Laravel Docker running on port 8000" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup CodeBuild build spec file
&lt;/h2&gt;

&lt;p&gt;According to AWS CodeBuild documentation, A build spec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;buildspec.yml&lt;/code&gt; file must be named as is and should be placed in the root of the project folder. However, you can give the buildspec file an alternate name or store it in a different location using the AWS CLI or AWS Cloudformation.&lt;/p&gt;

&lt;p&gt;Create a buildspec.yml file and copy the code below into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.2&lt;/span&gt;

&lt;span class="na"&gt;phases&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;install&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;runtime-versions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;php&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;7.3&lt;/span&gt;
  &lt;span class="na"&gt;pre_build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# commands to be run before build&lt;/span&gt;
    &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo Logging in to Amazon ECR....&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws --version&lt;/span&gt;
    &lt;span class="c1"&gt;# login to Elastic container registry&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;eval $(aws ecr get-login --region us-east-1 --no-include-email | sed 's|https://||')&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;REPOSITORY_URI=&amp;lt;YOUR ECR REPOSITORY URI HERE&amp;gt;&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;IMAGE_TAG=&amp;lt;YOUR IMAGE TAG HERE&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo Build started on `date`&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo installing composer..&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;composer install&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo creating .env file..&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cp .env.example .env&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo generating app key&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;php artisan key:generate&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo Building the Docker image...&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker build -t $REPOSITORY_URI:latest .&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG&lt;/span&gt;
  &lt;span class="na"&gt;post_build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo Build completed on `date`&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo Pushing the Docker image...&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker image ls -a&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker push $REPOSITORY_URI:$IMAGE_TAG&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The build spec contains env, version, phases, artifacts, cache, etc. We will be using just version and phases.&lt;/p&gt;

&lt;p&gt;The version which is required represents the build spec version. We will use version 2.0 — the recommended version. The &lt;code&gt;phases&lt;/code&gt;, also required, describes the command to be executed during the respective build phases.&lt;/p&gt;

&lt;p&gt;For a more in-depth understanding of the build spec file, &lt;a href="https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html"&gt;go here&lt;/a&gt; to read more.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;install&lt;/code&gt; phase, we specified a &lt;code&gt;php 7.3&lt;/code&gt; runtime version. The runtime-version parameter is required since we will be using the Ubuntu standard image 2.0&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;pre_build&lt;/code&gt; phase, we check the aws cli version and also attempt to login to AWS Elastic Container Registry. we also define the registry repository URI and the image tag.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;build&lt;/code&gt; phase, we install composer, create the Laravel environment file and also generate an application key. Finally, we build the docker image and assign it a tag.&lt;/p&gt;

&lt;p&gt;Note: make sure you specify the AWS region you’re working in in the &lt;code&gt;pre_build&lt;/code&gt; phase command that logs you into AWS ECR:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;aws ecr get-login&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1 ....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, in the &lt;code&gt;post_build&lt;/code&gt; phase, we push the docker image to the AWS ECR repository.&lt;/p&gt;

&lt;p&gt;Our Laravel Application is now set for deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an Elastic Container Registry Repository
&lt;/h2&gt;

&lt;p&gt;Let's create an image registry where we will store the Laravel docker image.&lt;/p&gt;

&lt;p&gt;Navigate the ECR dashboard on AWS Console.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q3bLDHeC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3830/1%2AHMO-JWr03982HxoSLE5BCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q3bLDHeC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3830/1%2AHMO-JWr03982HxoSLE5BCQ.png" alt="console" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the Create Repository button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O-b4PjZc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3838/1%2AcX5KMFzlLsi1_9OKPQxEAw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O-b4PjZc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3838/1%2AcX5KMFzlLsi1_9OKPQxEAw.png" alt="console" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Define the Repository name. I have named mine &lt;code&gt;gbxnga/laravel-docker-aws&lt;/code&gt; and click Create Repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q3ZVOWIo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3826/1%2A1yOl7MJZa84oeBSXCoYACQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q3ZVOWIo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3826/1%2A1yOl7MJZa84oeBSXCoYACQ.png" alt="ECR Repository" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once that’s done, copy the URI of the repository and paste it in the &lt;code&gt;pre_build&lt;/code&gt; phase of the build spec file.&lt;/p&gt;

&lt;p&gt;Also, Set the &lt;code&gt;IMAGE_TAG = 1.0&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pre_build:
commands:

    ...
- REPOSITORY_URI=650749741049.dkr.ecr.ap-southeast-2.amazonaws.com/gbxnga/laravel-docker-aws
    - IMAGE_TAG=1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ECR repository is now set. Container Images for our Laravel Application can now be stored on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure AWS CodeBuild
&lt;/h2&gt;

&lt;p&gt;Let's configure CodeBuild on the AWS Console. Log in to the AWS Console and navigate to the CodeBuild dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X2q_FLkG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3766/1%2A6xUP3IeAQvkYcbW0O9MdEQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X2q_FLkG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3766/1%2A6xUP3IeAQvkYcbW0O9MdEQ.png" alt="AWS CodeBuild" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will probably see the above Get Started screen if you’re using CodeBuild for the first time in the current region.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a CodeBuild Project
&lt;/h3&gt;

&lt;p&gt;Click on Create Project to create a build project. You will be taken to a build project creation page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K_44eQNk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3670/1%2AeMWnJZCqE1HcjfXjrRg_Lg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K_44eQNk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3670/1%2AeMWnJZCqE1HcjfXjrRg_Lg.png" alt="Create a CodeBuild build project" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give the project name. I have in this case named the build project &lt;code&gt;laravel-docker-aws&lt;/code&gt;. You can skip the &lt;code&gt;Description&lt;/code&gt; box as its optional.&lt;/p&gt;

&lt;p&gt;Scroll down to the Source section below. This is where the source provider for the project will be specified.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lFGFD3VP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3670/1%2ADUtTroFnrQVMSpfR6ISIow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lFGFD3VP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3670/1%2ADUtTroFnrQVMSpfR6ISIow.png" alt="Specify CodeBuild source" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select Github in this case. Make sure you have pushed the Laravel project containing the dockerfile, docker folder and the build spec file we created.&lt;/p&gt;

&lt;p&gt;Click on the OAuth button. You will be asked to authorize AWS CodeBuild with your GitHub account.&lt;/p&gt;

&lt;p&gt;Once that's done, check “Repository in my GitHub account”, then select the repository you pushed the Laravel app to.&lt;/p&gt;

&lt;p&gt;Scroll down to the Primary source webhook events section. Check the rebuild option then select the &lt;code&gt;PUSH&lt;/code&gt; Event Type. This tells CodeBuild to rebuild the image every time a PUSH is made to the selected GitHub repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e_L_2Bes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3654/1%2ACtaPWMN48spWWYKNYupL1Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e_L_2Bes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3654/1%2ACtaPWMN48spWWYKNYupL1Q.png" alt="Event type" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down to the Environment section&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--chdxr694--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3650/1%2AGJCqhdS8jXFlAF83SuDpeQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--chdxr694--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3650/1%2AGJCqhdS8jXFlAF83SuDpeQ.png" alt="Environment Section" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose Managed image as Environment Image and also the Ubuntu Operating System. Select the Standard Runtime and the &lt;code&gt;aws/codebuild/standard:2.0&lt;/code&gt; Image. Check the Privileged box and also New Service Role.&lt;/p&gt;

&lt;p&gt;Leave the Buildspec Section as is, but make sure the Use a buildspec file option is checked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xxhnm9c2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3614/1%2Ah6ncQ1A2DaPGRruSooz-zQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xxhnm9c2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3614/1%2Ah6ncQ1A2DaPGRruSooz-zQ.png" alt="Image" width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leave every other section as is, scroll all the way down and click the Create build project button.&lt;/p&gt;

&lt;p&gt;The CodeBuild project will now be created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eYedU74x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3662/1%2AgNh-cl66gcGsnFI6XFERbQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eYedU74x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3662/1%2AgNh-cl66gcGsnFI6XFERbQ.png" alt="Laravel AWS CodeBuild project" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create ECR access IAM Policy for CodeBuild
&lt;/h2&gt;

&lt;p&gt;In the post build phase of the build spec file, we attempt to push the docker image to AWS ECR. To successfully achieve this, we need to authorize the necessary action for CodeBuild.&lt;/p&gt;

&lt;p&gt;We will do this by creating an IAM Policy that grants full access to the AWS ECR repository we just created, then attach it to the service role that was automatically created for the code build project we just created.&lt;/p&gt;

&lt;p&gt;Navigate to IAM on the AWS Console then click on Roles.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QNIxMf_E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3758/1%2AvCOvGAkCvPEEYYCJKqpKiA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QNIxMf_E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3758/1%2AvCOvGAkCvPEEYYCJKqpKiA.png" alt="Image" width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look/Search for &lt;code&gt;codebuild-laravel-docker-aws-service-role&lt;/code&gt; role.&lt;/p&gt;

&lt;p&gt;Note that its likely the default name given to the code build project service role may be different. But if you named your build project laravel-docker-aws, the service role name will most likely be the same as the above.&lt;/p&gt;

&lt;p&gt;Click on the &lt;code&gt;codebuild-laravel-docker-aws-service-role&lt;/code&gt; role.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YH0X0fiP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3774/1%2AWdNC4Yg4RwOl2_6bCkkzJA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YH0X0fiP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3774/1%2AWdNC4Yg4RwOl2_6bCkkzJA.png" alt="Image" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will attach the Amazon managed AmazonEC2ContainerRegistryPowerUser policy to the service role.&lt;/p&gt;

&lt;p&gt;Click on Attach Policies button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--koiumo8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3826/1%2AFFB_CkaggZULQ_0p1PHxjQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--koiumo8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3826/1%2AFFB_CkaggZULQ_0p1PHxjQ.png" alt="Attach policies" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search for and select the &lt;code&gt;AmazonEC2ContainerRegistryPowerUser&lt;/code&gt; policy then click Attach Policy.&lt;/p&gt;

&lt;p&gt;The policy will now be attached, granting CodeBuild power user access to the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build the Laravel Docker Image
&lt;/h2&gt;

&lt;p&gt;Now that we have granted CodeBuild access to ECR, and we have configured our CodeBuild project, let’s initiate a build process for the Laravel docker image.&lt;/p&gt;

&lt;p&gt;Navigate to the CodeBuild dashboard on AWS console. Click on the &lt;code&gt;laravel-docker-aws&lt;/code&gt; CodeBuild project, then click the Start Build button to initiate a build process.&lt;/p&gt;

&lt;p&gt;Click on the build project to see more information on whats happening.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BBAlOSIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3710/1%2A8VW5wX_TMdMcob51wdWkMQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BBAlOSIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3710/1%2A8VW5wX_TMdMcob51wdWkMQ.png" alt="CodeBuild building a docker image" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down and Click on tail logs to see the build logs&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3OKUntHt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3778/1%2Ayr3GOc62oubd2Wv5HjFI8A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3OKUntHt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3778/1%2Ayr3GOc62oubd2Wv5HjFI8A.png" alt="AWS CodeBuild process logs" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait for the build process to complete. It make take a few minutes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cwsO1Hhq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3806/1%2AzNTbzjA14GTCO9c1P_yyqQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cwsO1Hhq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3806/1%2AzNTbzjA14GTCO9c1P_yyqQ.png" alt="Image" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CodeBuild has now successfully built and pushed our docker image to the ECR repository.&lt;/p&gt;

&lt;p&gt;Navigate to ECR dashboard to see the list of images in the &lt;code&gt;laravel-docker-aws repository&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RrDRs67h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3830/1%2A0TcNjzXKIgZEd7F8Srwpxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RrDRs67h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3830/1%2A0TcNjzXKIgZEd7F8Srwpxg.png" alt="Image" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy out the Image URI. We will be needing it to setup ECS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup AWS Elastic Container Service (ECS)
&lt;/h2&gt;

&lt;p&gt;Now that we have created our docker image and pushed it to AWS ECR, we will make use of AWS ECS to run it.&lt;/p&gt;

&lt;p&gt;Navigate to ECS dashboard on the AWS console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xR-i9EnL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3774/1%2AM-QCLmZJ-DskmghdrjHS7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xR-i9EnL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3774/1%2AM-QCLmZJ-DskmghdrjHS7g.png" alt="AWS Elastic Container Service (ECS)" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Amazon ECS Cluster
&lt;/h3&gt;

&lt;p&gt;Click on Clusters on the side menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8k3u0fGA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3810/1%2A-RBx83lpwKzksw77vhCQPg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8k3u0fGA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3810/1%2A-RBx83lpwKzksw77vhCQPg.png" alt="AWS ECS Cluster" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the Create Cluster button&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J6Qmomzb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3706/1%2AJlTjisSl8QjiZtEp-J1k6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J6Qmomzb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3706/1%2AJlTjisSl8QjiZtEp-J1k6w.png" alt="Create AWS ECS Cluster" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select EC2 Linux + Networking, and proceed to the next step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c4dNfi3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3694/1%2AzTnUvJUh2psN-6IrgOYTTg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c4dNfi3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3694/1%2AzTnUvJUh2psN-6IrgOYTTg.png" alt="Create AWS ECS Cluster" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give a name to the cluster. I have, in this case, named it &lt;code&gt;laravel-docker-aws-cluster&lt;/code&gt; and select the &lt;code&gt;t2.micro&lt;/code&gt; EC2 instance type.&lt;/p&gt;

&lt;p&gt;Leave every other parameter as is in the Instance configuration section and the Networking section.&lt;/p&gt;

&lt;p&gt;Make sure that a new role is to be created in the Container instance IAM role section if you haven’t already created the &lt;code&gt;ecsInstanceRolerole&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Click the Create button at the bottom to initiate the creation process for the ECS Cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6L4OdPhj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3730/1%2AXjCwstccKbqgPb9XE6smtQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6L4OdPhj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3730/1%2AXjCwstccKbqgPb9XE6smtQ.png" alt="AWS ECS creating a Cluster" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Cluster has been successfully created, click on the View Cluster button at the top to view the created cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O1vKK3Xb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3674/1%2AKWHjM_Y-0BoqBvJC145O2A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O1vKK3Xb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3674/1%2AKWHjM_Y-0BoqBvJC145O2A.png" alt="Image" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking on the ECS Instances tab, you can see the &lt;code&gt;t2.micro&lt;/code&gt; instance provisioned in the cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YBbnYpZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3082/1%2AWr12oVoTGYcR_CGmMcXMQw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YBbnYpZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3082/1%2AWr12oVoTGYcR_CGmMcXMQw.png" alt="ECS Instances" width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create AWS ECS Task Definition
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Task definitions specify the container information for your application, such as how many containers are part of your task, what resources they will use, how they are linked together, and which host ports they will use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Click on Task Definitions on the side menu, then click the Create new Task Definition button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yLALCeC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3778/1%2Axo3SguCHdpKkGWCdn3ll6Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yLALCeC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3778/1%2Axo3SguCHdpKkGWCdn3ll6Q.png" alt="Image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select EC2 and proceed to the next step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lilNg5DA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3666/1%2AsYlcSrXuP78ISE5vlq0wug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lilNg5DA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3666/1%2AsYlcSrXuP78ISE5vlq0wug.png" alt="Image" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give the task definition a name. Leave the Task role and Network Mode parameters as is.&lt;/p&gt;

&lt;p&gt;Scroll down to Container Definitions and click Add Container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FeTRfiWK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3698/1%2AbMd3vpXqnznQpPurLMA_vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FeTRfiWK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3698/1%2AbMd3vpXqnznQpPurLMA_vg.png" alt="Image" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Specify a container name &lt;code&gt;laravel-docker-aws-container&lt;/code&gt; . Also specify image repository URI.&lt;/p&gt;

&lt;p&gt;Make sure you specify the image tag(1.0 or the new tag if you chose to use another).&lt;/p&gt;

&lt;p&gt;Specify a Memory limit of 128MiB&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SJB0X7Je--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3722/1%2ACnlqiNOOUl9pRYiTzyuK8Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SJB0X7Je--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3722/1%2ACnlqiNOOUl9pRYiTzyuK8Q.png" alt="Image" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down to Port Mappings and specify the Host Port as &lt;code&gt;80&lt;/code&gt; and Container Port as &lt;code&gt;80&lt;/code&gt;. This means that port &lt;code&gt;80&lt;/code&gt; on the EC2 instance will be mapped to port &lt;code&gt;80&lt;/code&gt; on the Laravel docker container.&lt;/p&gt;

&lt;p&gt;Leave every other thing as is, scroll down and click Add.&lt;/p&gt;

&lt;p&gt;Once you have added the container, scroll down and click on Create to create the task definition.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xbzCJF-j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3734/1%2AdP32t_lFoDg-B1RQrisIUg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xbzCJF-j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3734/1%2AdP32t_lFoDg-B1RQrisIUg.png" alt="Image" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that the task definition has been created, we need to run the task.&lt;/p&gt;

&lt;p&gt;Click on Actions and select Run Task.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Dyl5L9zP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3758/1%2ARENMCiE4AByHqlIuIQK7TQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Dyl5L9zP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3758/1%2ARENMCiE4AByHqlIuIQK7TQ.png" alt="Image" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select EC2, leave other parameters as is and click Run Task.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DFJKi6R6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3718/1%2A_JuXWLq1dLscGz0qg51ODA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DFJKi6R6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3718/1%2A_JuXWLq1dLscGz0qg51ODA.png" alt="Image" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The task is now running on the &lt;code&gt;laravel-docker-aws-cluster&lt;/code&gt; that contains the &lt;code&gt;t2.micro&lt;/code&gt; instance.&lt;/p&gt;

&lt;p&gt;Navigate to EC2 dashboard on AWS console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9oOYD745--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3754/1%2A-uJkEcXnFCRywTPzD_ZdfQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9oOYD745--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3754/1%2A-uJkEcXnFCRywTPzD_ZdfQ.png" alt="Image" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the IP of the EC2 instance and paste it in your browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ta2qYv4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3802/1%2As8e8IOmXY2JrwdNO76GcEw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ta2qYv4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/3802/1%2As8e8IOmXY2JrwdNO76GcEw.png" alt="Laravel Docker running container on AWS ECS" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our Laravel docker container is now running.&lt;/p&gt;

&lt;p&gt;That’s it. You’ve successfully deployed and run a docker image on EC2 with AWS ECS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we set up docker for a Laravel application. We also implemented CodeBuild to build the docker image, pushing it to Elastic Container Registry. Finally, we setup Elastic Container Service to run the image on Amazon EC2.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>laravel</category>
      <category>docker</category>
      <category>awsecs</category>
    </item>
  </channel>
</rss>
