<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sommer Shurbaji on Medium]]></title>
        <description><![CDATA[Stories by Sommer Shurbaji on Medium]]></description>
        <link>https://medium.com/@sommershurbaji?source=rss-903fd5161923------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BsjLXDTLT71123wflJtmgA.png</url>
            <title>Stories by Sommer Shurbaji on Medium</title>
            <link>https://medium.com/@sommershurbaji?source=rss-903fd5161923------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:28:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sommershurbaji/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mathematics You Should Know To Understand Neural Networks]]></title>
            <link>https://sommershurbaji.medium.com/mathematics-you-should-know-to-understand-neural-networks-8f7c8f898595?source=rss-903fd5161923------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f7c8f898595</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Sommer Shurbaji]]></dc:creator>
            <pubDate>Fri, 05 Mar 2021 21:40:47 GMT</pubDate>
            <atom:updated>2021-03-16T15:19:52.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-051M-qWyqkiIRUVK1dEw.jpeg" /></figure><p>I started learning about neural networks a few months ago and I quickly realized that there were certain mathematical topics that were essential to understand in order to understand neural networks. Calculus and linear algebra are really important topics to be familiar with and it had been years since I had taken those courses in university. I thought it would be useful to consolidate some learning resources in one place that would help a beginner get started.</p><h4>Do I need a math degree to build neural networks?</h4><p>Short answer: absolutely not! There are tons of libraries out there that implement the complex mathematics for us and you definitely don’t need a math degree to build neural networks. However, having a basic understanding of the math behind neural networks is really important to understanding how they work in case you need to debug or optimize your algorithm.</p><p>The next section of this article describes the different pieces of a basic neural network, the mathematical concepts required, and links to videos explaining the concepts. If you’ve taken university level calculus and linear algebra, the resources I’ve linked will be a refresher for you. If you’ve never taken these courses, I recommend doing a more comprehensive course beyond the resources linked in this article so that you can gain the foundational knowledge required. These are two comprehensive online courses that are great options for learning the concepts in detail:</p><ul><li><a href="https://www.udemy.com/share/102mIC/">Udemy: Complete Maths for Machine Learning</a></li><li><a href="https://www.coursera.org/specializations/mathematics-machine-learning">Coursera: Mathematics for Machine Learning Specialization</a></li></ul><h4>Where can I learn about neural networks?</h4><p>If you’re interested in diving deeper into the topic of deep learning, I highly recommend this <a href="https://www.coursera.org/specializations/deep-learning">deep learning specialization</a> I enrolled in offered through Coursera. It’s a really well put together program taught by Andrew Ng, one of the leaders in the AI space.</p><h3>Mathematics you should know to understand neural networks</h3><h4>What is a Neural Network?</h4><p>A neural network is a network of algorithms used to solve classification problems. For example, a neural network can be used to tell you if an image is showing a cat or a dog.</p><p>Figure 1 shows a very basic image of a neural network. The main pieces of a neural network are:</p><ul><li>Input layer</li><li>Hidden layer (there can be several of these)</li><li>Output layer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*a0udL77MY5K31r4vbzvKoQ.png" /><figcaption>Figure 1</figcaption></figure><h4>Input Layer</h4><p>The input layer is the layer that contains the inputs we want to feed into our algorithm, also known as a <em>model</em>. Our algorithm will do some calculations using our inputs and then spit out an answer.</p><p>The input layer is usually represented as a <em>vector</em> of numbers. For our image example, how do we turn an image into a vector of numbers? Since the image is just a <em>matrix</em> of <em>RGB </em>values, we can just <em>unroll </em>or <em>flatten</em> the matrix of values into a vector of numbers to be used in our algorithm.</p><p>The resources below will go over <em>vectors</em> and <em>matrices,</em> the first major mathematical concepts you should know to understand neural networks.</p><p><strong>Resources</strong></p><ul><li><a href="https://www.youtube.com/watch?v=ihNZlp7iUHE">Khan Academy: Intro to vectors and scalars</a></li><li><a href="https://www.youtube.com/watch?v=xyAuNHPsq-g">Khan Academy: Intro to matrices</a></li></ul><h4>Hidden Layer</h4><p>The hidden layer(s) is where a lot of the action happens in a neural network. In Figure 1, notice that the layer is split into two portions: the weighted sum calculation and the activation calculation. I won’t go into too much detail about <em>why</em> these calculations are done (deep learning courses will dive into this topic), but I will outline the mathematical concepts you should practice to understand how they work.</p><p><strong>Weighted Sum</strong></p><p>The weighted sum, also known as a <em>dot product</em> is used to compute a value specified as the <em>z</em> value in Figure 1. It uses 3 variables: w, x, and b. W is a matrix of numbers that represent weights, which are initialized before computation. Even though it looks like w and x are being multiplied, there is actually a dot product happening.</p><p>W has an exponent <em>T</em>, which is not really an exponent, it represents <em>w transpose. </em>B is a<em> </em>bias, which is just a number that is initialized before computation. X is the input vector from the previous layer. You don’t have to worry about how w and b are initialized, since it will be outlined later in this article. The resources below will go over the dot product, matrix transpose, and matrix multiplication.</p><p><strong>Resources</strong></p><ul><li><a href="https://www.youtube.com/watch?v=KDHuWxy53uM">Khan Academy: Dot product</a></li><li><a href="https://www.youtube.com/watch?v=TZrKrNVhbjI">Khan Academy: Matrix transpose</a></li><li><a href="https://www.youtube.com/watch?v=OMA2Mwo0aZg">Khan Academy: Matrix multiplication</a></li></ul><p><strong>Activation</strong></p><p>The activation calculation is the calculation used to generate the <em>a </em>value in Figure 1. The activation calculation uses a <em>sigmoid </em>function with a <em>parameter</em> of z that was calculated previously. Not all neural networks use a sigmoid function, this is normally used as a starter for simple neural networks. The sigmoid function is used as part of a l<em>ogistic regression</em> model. The resources below will go over the sigmoid function and logistic regression.</p><p><strong>Resources</strong></p><ul><li><a href="https://www.youtube.com/watch?v=Aj7O9qRNJPY">ritvikmath: The Sigmoid</a></li><li><a href="https://www.youtube.com/watch?v=yIYKR4sgzI8">StatQuest: Logistic Regression</a></li></ul><h4><strong>Forward Propagation</strong></h4><p>Forward propagation encompasses the calculations performed above, which includes passing data from the input layer to the hidden layer, making some calculations using our algorithms, then spitting out a prediction. However, sometimes our algorithm may not be accurate on the first try. Our algorithm might tell us that a cat picture is actually a dog picture most of the time, which is not correct. We can make improvements to our algorithm by doing a step called <em>back propagation.</em></p><h4>Back Propagation</h4><p>Back propagation is a step that allows us to make our algorithm better, also known as <em>training. </em>Earlier I mentioned that there is a matrix of weights and a bias used in the weighted sum calculation. There are techniques to initializing the weight and bias which is out of the scope of this article, but most of the time they don’t give accurate results right away. We can actually use back propagation to help us adjust the weight and bias to make our algorithm more accurate.</p><p><strong>Cost function</strong></p><p>A <em>cost function</em> is used to calculate how well the algorithm did. Different neural networks can use different cost functions, so it depends on the neural network you’re using. Our neural network example uses logistic regression that has an associated cost function. The cost function is shown in Figure 2. Don’t worry if the cost function looks a little scary, if you take a comprehensive course on neural networks the details will be explained. Even if you don’t understand the cost function right now, we can focus on some specific parts of the function so you’ll be better prepared to understand it later on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gmoEOybhg7Q6rKFqMw3oEw.png" /><figcaption>Figure 2</figcaption></figure><p>At the beginning of the function, there is a <em>sigma</em> symbol, which represents a <em>sum. </em>Another important part of the equation is the <em>log </em>or <em>logarithm. </em>The resources below will go over the sigma notation and logarithms.</p><p><strong>Resources</strong></p><ul><li><a href="https://www.youtube.com/watch?v=5jwXThH6fg4">Khan Academy: Sigma notation for sums</a></li><li><a href="https://www.youtube.com/watch?v=mQTWzLpCcW0">Khan Academy: Introduction to logarithms</a></li></ul><p><strong>Gradient descent</strong></p><p>Using our cost function, we can find the weight and bias parameters that minimize our cost so that we can make our algorithm more accurate. To minimize cost, a step called <em>gradient descent </em>is used. If you imagine that our function is a surface like in Figure 3, the idea is that we want to get to the <em>minima</em> (lowest point) of the surface to minimize cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*Ydgh1XRH660zzjsgWvXBNg.png" /><figcaption>Figure 3</figcaption></figure><p>Gradient descent involves some knowledge in calculus. You’ll need to understand derivatives and how you can get the<em> slope</em> of a function. The resources below will give you an overview of derivatives that will help you understand gradient descent.</p><p><strong>Resources</strong></p><ul><li><a href="https://www.youtube.com/watch?v=N2PpRnFqnqY">Khan Academy: Derivatives as a concept</a></li><li><a href="https://www.youtube.com/watch?v=rAof9Ld5sOg">Khan Academy: Calculus: Derivatives 1</a></li><li><a href="https://www.youtube.com/watch?v=ay8838UZ4nM">Khan Academy: Calculus: Derivatives 2</a></li><li><a href="https://www.youtube.com/watch?v=AXqhWeUEtQU">Khan Academy: Partial derivatives, introduction</a></li></ul><h3>Final thoughts</h3><p>So that’s it! Those are the main math resources that I thought would be really useful for a beginner in machine learning. Once you have a good understanding of the mathematical concepts outlined in this article, you’ll be in really great shape to dive into neural networks and deep learning. A topic that I didn’t cover in this article is statistics, which is also used in machine learning. You can get away without knowing statistics as a beginner and in the future I can add a statistics article as part of a math for machine learning series! I’d love to hear your questions or suggestions on future topics and thanks for reading! :)</p><p><strong>Image Sources</strong></p><ul><li>Figure 2: <a href="https://stats.stackexchange.com/questions/278771/how-is-the-cost-function-from-logistic-regression-derivated">https://stats.stackexchange.com/questions/278771/how-is-the-cost-function-from-logistic-regression-derivated</a></li><li>Figure 3: <a href="https://blog.paperspace.com/intro-to-optimization-in-deep-learning-gradient-descent/">https://blog.paperspace.com/intro-to-optimization-in-deep-learning-gradient-descent/</a></li></ul><h4>Disclaimer</h4><p>I’m an employee of IBM. The views expressed in this blog are mine and don’t necessarily reflect the positions, strategies, or opinions of the company.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f7c8f898595" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuous Delivery with AWS Elastic Beanstalk and Travis CI]]></title>
            <link>https://sommershurbaji.medium.com/continuous-delivery-with-aws-elastic-beanstalk-and-travis-ci-2dd54754965f?source=rss-903fd5161923------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dd54754965f</guid>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[travis-ci]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[elastic-beanstalk]]></category>
            <dc:creator><![CDATA[Sommer Shurbaji]]></dc:creator>
            <pubDate>Tue, 08 Aug 2017 02:25:00 GMT</pubDate>
            <atom:updated>2021-03-16T15:20:54.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*a96dh5kNx9M4xzB2EiRjuQ.png" /></figure><p>Elastic Beanstalk is a really awesome service provided by AWS that deploys, automatically scales and provisions your applications. If you’re interested in learning more, see my previous <a href="https://medium.com/@sommershurbaji/deploying-a-docker-container-to-aws-with-elastic-beanstalk-28adfd6e7e95">tutorial</a> on how to deploy a Docker container using Elastic Beanstalk! Deploying with Elastic Beanstalk is extremely easy if you use the CLI, API or management console in your AWS dashboard. But with those methods, every time you want to deploy your app, you need to manually fire up the CLI or log into your dashboard, which can be time consuming.</p><p>In this tutorial, I will show you how to add a Travis CI integration that will automatically deploy your application with Elastic Beanstalk whenever you push to your master branch on github. This integration will help you be on your way to achieving a continuous delivery model!</p><p>Feel free to skip to part 2 of the tutorial if you already have Travis CI enabled with your application.</p><h3>Prerequisites:</h3><ol><li>You have an application with Elastic Beanstalk configuration set up. I assume that you are able to manually deploy to Elastic Beanstalk. Feel free to <a href="https://github.com/sommercodes/elastic-beanstalk-tutorial">clone</a> my simple Node.js and Docker app from my previous tutorial that has the Travis CI configuration set up to follow along with. You are not required to use Node.js or Docker, they are just the technologies I used in this example.</li><li>Your app should be on github since in this tutorial, we will be using the github Travis CI configuration.</li><li>Set up your favorite text editor. I like to use <a href="https://code.visualstudio.com/">Visual Studio Code</a></li></ol><h3>Part 1: Add Travis CI integration to your Application</h3><p>To add a Travis CI integration to your application, navigate to the settings tab on your app’s github page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*QpF-ARK4g7HSlT-1GbdxIw.png" /></figure><p>On the settings page, navigate to Integrations and services:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*47PR5qpUO9Il3k_HwEsvkA.png" /></figure><p>Click the “Add Service” drop down, then search for and click on “Travis CI”. You will be presented with a form that asks for User, Token, Domain. You don’t need to fill anything out, just click on the “add service” button. Now your services page should contain Travis CI in the list of services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*3KYEL06m75bdoFykfZ8jGw.png" /></figure><p>Now that we’ve added Travis to the repo, sign into <a href="https://travis-ci.org/">https://travis-ci.org/</a>. Add your new repository by clicking on the “+” sign in your list of repos. Make sure you sync your github account if your repo is not visible in the list. Find your repo, and then flick the repository switch on. Now Travis has been enabled! Now every time you push code to your repo, a Travis build will be triggered</p><p>The next thing we need to do is add a .travis.yml file that tells Travis CI how to build our application. First we will add an extremely simple .travis.yml and test that our builds get triggered. Add a .travis.yml file in your repo’s top level directory. Below is the starter travis config file that I added. The Docker service is not required if you are not using Docker. If you are not using Node.js, you’re .travis.yml will need to have the correct configurations for the language that you are using.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/849f0c76ca7276963b74bf35e5f73fd2/href">https://medium.com/media/849f0c76ca7276963b74bf35e5f73fd2/href</a></iframe><p>Now commit and push your .travis.yml file. You can monitor that the build has started by navigating to the repo on the Travis CI page. Below is an example of a build in progress:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kayl0AckwsteNfRzpOM3ww.png" /></figure><p>Once your build passes, we can add the Elastic Beanstalk configuration to deploy your application automatically.</p><h3>Part 2: Integrate Elastic Beanstalk with your Travis CI build</h3><p>Now we can add the Elastic Beanstalk configuration to our .travis.yml. Append the following configuration below to your .travis.yml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c580c9e3eee65dc776b443addf551b3/href">https://medium.com/media/2c580c9e3eee65dc776b443addf551b3/href</a></iframe><p>Before pushing the updated .travis.yml configuration there are a few things that need to be done:</p><ol><li>Edit the region, app, env, and bucket_name to match the configurations of your app. Bucket_name corresponds to the S3 bucked that your source code is added to every time you deploy your app.</li><li>Change the “on branch” configuration to match the branch that you would like to use as the “deploy” branch. I use master in this example, so that if you push to master, there will be a deployment, and no deployment on any other branch. If you omit this section, your app will be deployed every time you push code to any branch.</li><li>For the access key id and secret access key, I added environment variables to my repo’s Travis settings within the Travis UI and reference them in the .travis.yml to prevent my access keys from being pushed to source control. You can get your access keys by visiting the IAM tab in your AWS management console and you either need to create a new user or use the keys from an existing user that you have saved. Add these keys as secure environment variables to your repo’s settings in the Travis CI dashboard.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*O0JJBWcRK--tBIx1Pzx5aw.png" /></figure><p>Now push your updated .travis.yml file and wait for the build to start!</p><p>Once your build finishes and succeeds, the log should show some information about your application’s deployment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZzBZKoSvpA7gbvnnntDjQ.png" /></figure><p>If you navigate to your Elastic Beanstalk dashboard page and view your application, it should say that the application is being updated and should complete updating after a few minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0gWBKG4PakoQKktGVXq2A.png" /></figure><h3>Closing Thoughts:</h3><p>With a few button clicks and lines of code, we have added automatic deployment to our Elastic Beanstalk environment! Overall, Travis CI makes it super easy to add Continuous Integration/Continuous Deployment to your application’s development process by providing cool integrations like Elastic Beanstalk that allow you to deploy automatically. This is just one simple example using Travis CI, but feel free to explore Elastic Beanstalk deployments with other tools like Circle CI, Jenkins, and more!</p><p>Happy Coding !! 😄</p><h4>Disclaimer</h4><p>I’m an employee of IBM. The views expressed in this blog are mine and don’t necessarily reflect the positions, strategies, or opinions of the company.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dd54754965f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Docker Container to AWS with Elastic Beanstalk]]></title>
            <link>https://sommershurbaji.medium.com/deploying-a-docker-container-to-aws-with-elastic-beanstalk-28adfd6e7e95?source=rss-903fd5161923------2</link>
            <guid isPermaLink="false">https://medium.com/p/28adfd6e7e95</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[elastic-beanstalk]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Sommer Shurbaji]]></dc:creator>
            <pubDate>Tue, 08 Aug 2017 00:55:34 GMT</pubDate>
            <atom:updated>2021-03-16T15:21:38.341Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*Iht_7syjADjA3ndAzaAs1Q.jpeg" /></figure><h3>Overview:</h3><p>Elastic Beanstalk is an AWS service that leverages Amazon EC2 and S3 and deploys, manages and scales your web applications for you. It uses managed containers that support Node.js, Java, Ruby, Docker and more. There are multiple ways to deploy applications using Elastic Beanstalk. You can deploy using the management console, the CLI, or the API. The amazing thing about Elastic Beanstalk is that once you upload your application, it takes care of things like load balancing, health monitoring, scaling, and more. Check out more information on <a href="https://aws.amazon.com/elasticbeanstalk/?sc_channel=PS&amp;sc_campaign=acquisition_CA&amp;sc_publisher=google&amp;sc_medium=beanstalk_b&amp;sc_content=elastic_beanstalk_e&amp;sc_detail=amazon%20elastic%20beanstalk&amp;sc_category=beanstalk&amp;sc_segment=200655922064&amp;sc_matchtype=e&amp;sc_country=CA&amp;s_kwcid=AL!4422!3!200655922064!e!!g!!amazon%20elastic%20beanstalk&amp;ef_id=WYiDngAAA2XkYcnn:20170807235428:s">Elastic Beanstalk</a>! Overall, Elastic Beanstalk builds your docker image using your uploaded source code, and then it is deployed to EC2 instances running in an Elastic Beanstalk environment.</p><p>In this tutorial we will:</p><ul><li>Deploy our Docker container with Elastic Beanstalk using a single container configuration (run 1 container per EC2 instance), using the Elastic Beanstalk CLI. (Stay tuned for more tutorials on how to deploy using other methods)</li><li>Use a Dockerfile for our configuration for simplicity, instead of a Dockerrun.aws.json definition file that is a second config option with Elastic Beanstalk.</li></ul><p>There are 3 parts to this tutorial: creating the app, dockerizing the app, and deploying the app with Elastic Beanstalk. You are not limited to use the Node.js app that I create in this tutorial, feel free to skip parts 1 and 2 if you either have a dockerized app already, or if you <a href="https://github.com/sommercodes/elastic-beanstalk-tutorial">download</a> and set up the Node.js app that I have provided on github. The app that I create below is the same app that I provide on github, but with some additional Travis CI configurations.</p><h3>Prerequisites:</h3><ol><li><a href="https://aws.amazon.com/free/?sc_channel=PS&amp;sc_campaign=acquisition_CA&amp;sc_publisher=google&amp;sc_medium=cloud_computing_hv_b&amp;sc_content=aws_core_e&amp;sc_detail=aws&amp;sc_category=cloud_computing&amp;sc_segment=84661158296&amp;sc_matchtype=e&amp;sc_country=CA&amp;s_kwcid=AL!4422!3!84661158296!e!!g!!aws&amp;ef_id=WYiDngAAA2XkYcnn:20170807153337:s">Create</a> an AWS account. AWS offers a free tier with access to a lot of cool services such as Amazon EC2 and S3.</li><li>Download the Elastic Beanstalk (EB) command line tool which we will use in this tutorial to deploy our docker container manually from our machine. Follow these instructions on how to <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html">set up the EB CLI</a>.</li><li>Download the latest version of <a href="https://nodejs.org/en/">Node.js</a> (if you follow part 1)</li><li>Download <a href="https://docs.docker.com/engine/installation/#supported-platforms">Docker</a>.</li><li>Download and install <a href="https://git-scm.com/downloads">Git</a>. Git is used by EB CLI to deploy your last committed code.</li><li>Set up your favorite text editor. I like to use <a href="https://code.visualstudio.com/">Visual Studio Code</a></li></ol><h3>Part 1: Creating our application</h3><p>I will first be creating a very simple Node.js application which I will dockerize in part 2 of the tutorial.</p><ul><li>Create a directory that will hold your application, I called mine “elastic-beanstalk-tutorial”.</li><li>Open a command prompt and change into your project’s root directory. Initialize your project by running npm init -f. . After running the initialize function, npm will create a package.json for you.</li><li>Create a new file in your project’s root directory called app.js. In app.js add the contents below:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89ba63075105bb4ed7ca5a89daaab1d1/href">https://medium.com/media/89ba63075105bb4ed7ca5a89daaab1d1/href</a></iframe><p>App.js contains code that runs a very simple web server using express, and logs requests using morgan.</p><ul><li>Now we need to install our dependencies using npm install --save express morgan , which will install and add our dependencies to the package.json.</li><li>Add a start script to the scripts section of the package.json which we will need to use in the dockerization step: &quot;start&quot;: &quot;node app.js&quot;</li><li>Now to make sure everything is running fine, run npm start and you should see the console print App running at http://localhost:8080 . Open a web browser and you should see the text hello world!! displayed on the screen.</li></ul><h3>Part 2: Dockerizing our application</h3><p>Now that we have a very simple Node.js web server running, we can start dockerizing the application in preparation for deployment to AWS.</p><ul><li>Add a new file to your project’s root directory called “Dockerfile”. The Dockerfile will contain instructions to assemble your application into a Docker image. Below are the contents of the Dockerfile for this application:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e7528b08842669d3e01ca607ba1f3e1/href">https://medium.com/media/3e7528b08842669d3e01ca607ba1f3e1/href</a></iframe><p>The first line is specifying to use the node alpine base image. The alpine image is great if you need to create as small of an image as possible, since it is only about 5MB, but feel free to use any image you desire. The rest of the file contains standard Docker commands with instructions on which files get copied over and how to start the web server etc..</p><ul><li>Now add a new file called .dockerignore to your project’s root directory. The .dockerignore specifies which files and folders to ignore in the COPY step. In the .dockerignore, add the 2 lines below to ignore node modules and the npm debug log.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1500a84982216dfc0fa6d59ba66bdb9e/href">https://medium.com/media/1500a84982216dfc0fa6d59ba66bdb9e/href</a></iframe><ul><li>Now that our Docker configurations are set up, we can build and run our image for testing before we deploy with Elastic Beanstalk. Open a command prompt in your application’s root directory. <strong>Note:</strong> on Windows platforms, you might need to use the <em>Docker Quickstart Terminal</em> to run Docker commands, which comes packaged with Docker downloads on Windows.</li><li>In your terminal run the command docker build -t eb-tutorial . . This command will build your image and tag it with the name “eb-tutorial”. You can tag it with whichever name you would like. If there were no errors building the image, you can run docker images and your image should be in the list.</li><li>To run a container out of your newly created Docker image, use the command docker run -d -p 8080:8080 --name eb-tutorial eb-tutorial . The -d flag runs the container in detached mode, -p specifies the port configuration, and the name flag specifies the container name. Now running docker ps in the command prompt should show your running container. Navigate to http://localhost:8080 and you should see the “hello world!!” message once again. <strong>Note: </strong>if you are running on Windows, localhost will not work, you will need to navigate to<strong> </strong><a href="http://192.168.99.100:8080/">http://&lt;ip docker runs on&gt;:8080/</a>. The ip is usually displayed when Docker Quickstart Terminal first starts up.</li></ul><h3><strong>Part 3: Deploying our application with Elastic Beanstalk CLI</strong></h3><p>Woohoo! Now that we set up our Node.js app and Docker, we can finally deploy to AWS with Elastic Beanstalk!</p><ul><li>Open a terminal in your app’s root directory. The first command we will run (assuming you set up eb cli) is eb init . The init command configures Elastic Beanstalk for your project.</li><li>If it is your first time using eb cli, the first thing it will ask is for your user credentials, so paste in your access keys. If you do not have access keys, you will need to go to the <a href="https://console.aws.amazon.com/iam/home?region=ca-central-1#/users">IAM/Users </a>dashboard and create a new user with full access, or whichever access roles you would like provide that user. Then make sure to download the keys when it prompts you to and save them in a safe spot, since you will only have 1 chance to download them. Paste these keys into the command prompt.</li><li>The init command will then ask for other info like the region, name of the app etc.., just follow the prompts and enter the correct information. <strong>Note: </strong>the cli will detect you are using Docker since you have Docker configurations in your application. Also, I usually say no to setting up “code commit” and “ssh”.</li><li>Once the init command successfully finishes, notice there is a new directory in your project called .elasticbeanstalk which contains the generated configurations. Now we can create our new environment to deploy to by running eb create . Follow the prompts for this command as well. If you navigate to the Elastic Beanstalk service in the AWS management console, you will see that your new application is being created like below. It should take a few minutes for your application to be created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*NneI1NNDrNrxMaQh62zyJg.png" /><figcaption>pending deployment</figcaption></figure><ul><li>Once your application has successfully been created and deployed, it should look something like below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*pOhgeHVkxmeEntgb2NTTAw.png" /><figcaption>successful deployment</figcaption></figure><ul><li><strong>Important Note</strong>: I am using git with this tutorial, and if git is installed, EB CLI will only deploy the most recently committed code. Sometimes if you deploy and forget to commit your code, your application deployment could fail, or your app could behave unexpectedly. EB CLI will usually warn you in the command line if you deploy with uncommitted changes. More info on eb debploy <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-deploy.html">here</a>.</li><li>Click into your application and you should see a page like below. The health should be green, it should be running a Docker configuration. If you click the url that your app is running on, it will take you to your app, and you should see the same “hello world!!” message in the browser that you saw when you ran your app locally.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMqPU3sRcZx44W3z9mmSug.png" /></figure><p>Yay! we have successfully deployed our application with Elastic Beanstalk!!</p><p>As I mentioned in the overview section of this tutorial, your Docker container runs on an EC2 instance. If you would like to see your running EC2 instance, you can navigate to the EC2 dashboard in your management console and view it there, where you can gather information on the instance such as the type, state, and other information of your instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qL9twCGcXPoeSLGh-gFXbw.png" /><figcaption>EC2 console</figcaption></figure><h3>Closing Notes:</h3><p>And just like that, we’ve deployed our application to AWS using a few simple CLI commands! You don’t need to worry about manually setting up EC2 instances, provisioning, or scaling, it’s all done for you using Elastic Beanstalk!</p><p>Remember, with Elastic Beanstalk, you are not limited to using Docker or the CLI! Elastic Beanstalk gives you the option of using several languages and platforms as well as different ways of deploying your app that suit your needs.</p><p>Feel free to give me suggestions on other Elastic Beanstalk tutorials that you would like to see!</p><p>Happy Coding!! 😄</p><h4>Disclaimer</h4><p>I’m an employee of IBM. The views expressed in this blog are mine and don’t necessarily reflect the positions, strategies, or opinions of the company.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28adfd6e7e95" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>