<?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: Stephanie Albert</title>
    <description>The latest articles on DEV Community by Stephanie Albert (@stefanie-a).</description>
    <link>https://dev.to/stefanie-a</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%2F1133086%2F01824429-f6e5-4d2f-953e-b8ae210562f5.jpeg</url>
      <title>DEV Community: Stephanie Albert</title>
      <link>https://dev.to/stefanie-a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stefanie-a"/>
    <language>en</language>
    <item>
      <title>The World of Auto Scaling: What Really Happens Behind the Scenes</title>
      <dc:creator>Stephanie Albert</dc:creator>
      <pubDate>Tue, 12 Aug 2025 13:19:13 +0000</pubDate>
      <link>https://dev.to/stefanie-a/the-world-of-auto-scaling-what-really-happens-behind-the-scenes-4k78</link>
      <guid>https://dev.to/stefanie-a/the-world-of-auto-scaling-what-really-happens-behind-the-scenes-4k78</guid>
      <description>&lt;p&gt;It’s 2 PM, traffic is exploding, your servers are struggling, and you’re frantically trying to spin up more instances. Sound familiar? This is exactly why Auto Scaling exists, but most developers only understand the surface level. Auto Scaling gets talked about a lot, but often in vague terms: “It automatically adds servers when traffic spikes.” That’s true, but what’s really happening under the hood? How does AWS know when to add more instances? And how does your application code magically appear on those new instances ready to serve users?&lt;/p&gt;

&lt;p&gt;Let’s pull back the curtain and explore the fascinating orchestration that happens every time your application needs to scale.&lt;/p&gt;

&lt;p&gt;Auto Scaling in Plain Terms At its core&lt;br&gt;
Auto Scaling is not just in AWS, it’s a way of keeping your application available and responsive, no matter the traffic pattern. It does this by: Monitoring performance metrics (like CPU or requests per second) Deciding when to add or remove compute capacity based on predefined policies Provisioning new resources with the exact application setup you need But there’s a sophisticated orchestration happening between “metric breach” and “new server is live.”&lt;/p&gt;

&lt;p&gt;The Scale-Out Lifecycle&lt;br&gt;
Imagine your EC2-hosted application suddenly goes viral. Here’s the full sequence of what happens when AWS Auto Scaling decides to add a new instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyb2x1d9on2n9u82egewp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyb2x1d9on2n9u82egewp.png" alt=" " width="800" height="813"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 1 — The Trigger (0–30 seconds)&lt;br&gt;
Auto Scaling works with Amazon CloudWatch to track key metrics you define, such as: CPUUtilization &amp;gt; 70%, RequestCount per target &amp;gt; 1000 requests/min, Memory usage (via custom CloudWatch metrics) or Custom application metrics (queue length, response time). When a threshold is breached, CloudWatch sends a signal to your Auto Scaling Group. The timing here depends on your scaling policy type.&lt;/p&gt;

&lt;p&gt;Step 2 — Launching a New Instance (30–90 seconds)&lt;br&gt;
The Auto Scaling Group uses a Launch Template to create a new EC2 instance. That blueprint includes:&lt;/p&gt;

&lt;p&gt;AMI (Amazon Machine Image) → Base OS + optional pre-installed app code Instance type (e.g., t3.medium, c5.large)&lt;br&gt;
Security groups &amp;amp; IAM roles for proper access control&lt;br&gt;
User Data script to run commands at boot Storage configuration and network settings&lt;br&gt;
Key Pair to specify the key pair used for SSH access.&lt;br&gt;
Step 3 — Bootstrapping Your Application&lt;br&gt;
Here’s where your application code gets onto the new server. This can happen in two primary ways:&lt;/p&gt;

&lt;p&gt;Option A: Pre-baked AMI&lt;/p&gt;

&lt;p&gt;Your AMI already contains the full application stack Boot time is quick, just start the app services. This is suitable for applications with infrequent updates.&lt;/p&gt;

&lt;p&gt;Option B: Runtime Deployment&lt;/p&gt;

&lt;p&gt;The AMI is minimal (base OS only), the User Data script handles everything: Installs dependencies (Node.js, Python, Nginx, etc.), pulls the latest code from S3, CodeDeploy, or Git repository, runs configuration management tools (Ansible, Chef, AWS SSM) and configures environment variables and secrets. This is best for rapid development cycles with frequent deployments.&lt;/p&gt;

&lt;p&gt;Step 4 — Joining the Load Balancer Fleet&lt;br&gt;
Once the new instance is running and your application has bootstrapped, it needs to join the traffic distribution system:&lt;/p&gt;

&lt;p&gt;Target Group Registration: The Auto Scaling Group automatically registers the new instance with the configured Target Group(s)&lt;br&gt;
Health Check Initiation: The Load Balancer (ALB/NLB) starts performing health checks against the instance using the Target Group’s health check configuration&lt;br&gt;
Health Check Validation: The load balancer sends requests to your defined health check path (e.g., /health or /status) typically every 30 seconds&lt;br&gt;
Healthy Threshold: Requires 2–3 consecutive successful health checks (HTTP 200 responses) before the instance is marked as healthy&lt;br&gt;
Target Group Status: Instance transitions from “initial” → “healthy” status in the Target Group&lt;br&gt;
Traffic Routing: Once marked healthy in the Target Group, the Load Balancer begins routing requests to the new instance&lt;br&gt;
Step 5 — Serving Requests&lt;br&gt;
From the user’s perspective, nothing has changed they just get fast responses. Behind the scenes, the Load Balancer is distributing requests across both original and newly launched instances, all running identical code.&lt;/p&gt;

&lt;p&gt;Scale-In — The Reverse Process&lt;br&gt;
When traffic drops and you no longer need the extra capacity. CloudWatch detects metrics below your lower threshold Selection, Auto Scaling chooses an instance to terminate (oldest launch configuration first, then least billed hour). Connection gets drained (Load Balancer stops sending new requests and waits for existing connections to complete) and gracefully shutsdown. Instance receives termination signal, allowing apps to clean up before shutting down, and billing stops.&lt;/p&gt;

&lt;p&gt;Scaling Policies: The Brain Behind the Operation&lt;br&gt;
Understanding the different scaling policy types is crucial:&lt;/p&gt;

&lt;p&gt;Target Tracking Scaling Best for: Most use cases How it works: Maintains a specific metric target (e.g., 50% CPU) Example: Keep average CPU utilization at 70%&lt;br&gt;
Step Scaling Best for: Predictable traffic patterns How it works: Different scaling actions based on alarm breach size Example: Add 1 instance if CPU &amp;gt; 70%, add 3 instances if CPU &amp;gt; 90%&lt;br&gt;
Predictive Scaling Best for: Regular traffic patterns How it works: Uses machine learning to forecast and pre-scale Example: Scale up every weekday at 8 AM based on historical patterns&lt;br&gt;
Conclusion&lt;br&gt;
This Article transforms Auto Scaling from a mysterious black box to predictable, powerful tool once you understand the orchestration behind it. The next time you see those new instances spinning up during a traffic spike, you’ll know exactly what’s happening under the hood.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ec2</category>
      <category>autoscaling</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Kubernetes with aiops</title>
      <dc:creator>Stephanie Albert</dc:creator>
      <pubDate>Sat, 28 Jun 2025 17:07:06 +0000</pubDate>
      <link>https://dev.to/stefanie-a/kubernetes-with-aiops-4fd4</link>
      <guid>https://dev.to/stefanie-a/kubernetes-with-aiops-4fd4</guid>
      <description></description>
      <category>kubernetes</category>
      <category>aiops</category>
      <category>devops</category>
      <category>cloudnative</category>
    </item>
    <item>
      <title>Hosting a Static Website On S3 bucket With CloudFront.</title>
      <dc:creator>Stephanie Albert</dc:creator>
      <pubDate>Fri, 27 Sep 2024 17:07:30 +0000</pubDate>
      <link>https://dev.to/stefanie-a/hosting-a-static-website-on-s3-bucket-with-cloudfront-4llh</link>
      <guid>https://dev.to/stefanie-a/hosting-a-static-website-on-s3-bucket-with-cloudfront-4llh</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6kwlputte3c0osnp5zm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6kwlputte3c0osnp5zm.jpg" alt="Image description" width="429" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Overview
&lt;/h3&gt;

&lt;p&gt;In this article, you will learn how to deploy a simple website using HTML, CSS, and JavaScript using Amazon CloudFront and S3.&lt;/p&gt;

&lt;p&gt;Amazon Simple Storage Service (S3) allows you to host static websites by providing object level storage. It stores and retrives data as objects iwithin buckets, making it perfect for static website hosting.&lt;/p&gt;

&lt;p&gt;Amazon CLoudFront is a Content Delivery Network (CDN) service which utilizes a network of edge locations to cache copies of your website content closer to users, reducing latency and ensuring faster delivery.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Log in to AWS and Access S3
&lt;/h3&gt;

&lt;p&gt;Login to your AWS management console and search for s3 in the search bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flydc0aq8mw7ucwdv5qmz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flydc0aq8mw7ucwdv5qmz.png" alt="Image description" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create an S3 Bucket
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click on create a bucket&lt;/li&gt;
&lt;li&gt;Choose General purpose&lt;/li&gt;
&lt;li&gt;Enter a unique name for your bucket&lt;/li&gt;
&lt;li&gt;Ensure Block all public access is selected.
Leave the rest of the settings at their default values and click Create bucket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkiuhfb6qxgnrkn4v0rvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkiuhfb6qxgnrkn4v0rvk.png" alt="Image description" width="628" height="863"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Upload Website Files
&lt;/h3&gt;

&lt;p&gt;Once your bucket is successfully created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the newly created bucket.&lt;/li&gt;
&lt;li&gt;Upload your index.html, css , javascript , and any other static files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfu0svjj1xbh9qbodnuf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfu0svjj1xbh9qbodnuf.png" alt="Image description" width="596" height="711"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Set Up CloudFront Distribution
&lt;/h3&gt;

&lt;p&gt;Now, we'll set up a CloudFront Distribution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to CloudFront in AWS Console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3p60z60x5d3zdxn2o0f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3p60z60x5d3zdxn2o0f.png" alt="Image description" width="566" height="905"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click Create Distribution.&lt;/li&gt;
&lt;li&gt;Create a new Origin Access Control (OAC) to securely grant CloudFront access to your S3 bucket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qohyex4sjul69q7wgv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qohyex4sjul69q7wgv3.png" alt="Image description" width="420" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set Redirect HTTP TO HTTPS&lt;/li&gt;
&lt;li&gt;Since this is a basic tutorial, your website won't need WAF.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ym9u4ilyepzhqvukqfd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ym9u4ilyepzhqvukqfd.png" alt="Image description" width="800" height="567"&gt;&lt;/a&gt;&lt;br&gt;
Once you’ve completed the setup, AWS will create your CloudFront distribution. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Update the s3 Bucket Policy
&lt;/h3&gt;

&lt;p&gt;After creating the CloudFront distribution, you'll see a prompt asking you to update your S3 bucket policy. This step is important to allow CloudFront access the content in your bucket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj31g7o6j6z9kud8goix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj31g7o6j6z9kud8goix.png" alt="Image description" width="800" height="399"&gt;&lt;/a&gt;&lt;br&gt;
Copy the policy, head over to your s3 bucket permissions tab and paste the new policy in the Bucket Policy Editor and save the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh30vevt27tpj9r2196s1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh30vevt27tpj9r2196s1.png" alt="Image description" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Access Your Website
&lt;/h3&gt;

&lt;p&gt;Copy the Distribution Domain Name from CloudFront, open it in your browser, and you will see your static website!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91meeu2yxu9uuwy4gkel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91meeu2yxu9uuwy4gkel.png" alt="Image description" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;You've now successfully hosted a static website using Amazon S3 and Amazon CloudFront. With S3 providing scalable storage and CloudFront ensuring fast, reliable content delivery through its edge locations, your website is well-optimized for performance and availability.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>s3</category>
      <category>cloudfront</category>
      <category>website</category>
    </item>
    <item>
      <title>DEPLOYING APACHE WEB SERVER TO AWS EC2</title>
      <dc:creator>Stephanie Albert</dc:creator>
      <pubDate>Thu, 05 Sep 2024 13:25:37 +0000</pubDate>
      <link>https://dev.to/stefanie-a/deploying-apache-web-server-to-aws-ec2-e6h</link>
      <guid>https://dev.to/stefanie-a/deploying-apache-web-server-to-aws-ec2-e6h</guid>
      <description>&lt;h2&gt;
  
  
  INTRODUCTION
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Imagine you are working as a system administrator for a small e-commerce company. The company has a website hosted on shared hosting, but due to increased traffic and performance issues, your team has decided to migrate the website to a more scalable infrastructure using AWS.&lt;/p&gt;

&lt;p&gt;Your task is to set up a basic EC2 instance that will serve as the new web server for the company’s website. You’ll create and configure the instance, install a web server (Apache), and deploy a simple static HTML page that announces the migration.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Overview
&lt;/h3&gt;

&lt;p&gt;An Amazon EC2 instance is a cost-effective virtual server in the AWS cloud environment. You have full control over your instance, from the time that you first launch an instance until you terminate the instance. You can choose from a variety of operating systems when you launch your instance. Amazon EC2 provides a wide range of instance types. You can customize your instance to meet your needs by choosing a type that offers the compute resources, memory, storage, and network performance required to run your applications, paying only for what you use.&lt;/p&gt;

&lt;h3&gt;
  
  
  PREQUISITE :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;AWS Account&lt;/li&gt;
&lt;li&gt;Key Pair&lt;/li&gt;
&lt;li&gt;Security Group&lt;/li&gt;
&lt;li&gt;Web Server(Apache)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 1:
&lt;/h4&gt;

&lt;p&gt;Login into to your AWS management console, click on the search bar icon and search for EC2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkrpk7o1js72dwzcwvgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkrpk7o1js72dwzcwvgi.png" alt="Image description" width="800" height="477"&gt;&lt;/a&gt;&lt;br&gt;
Click on Launch instance&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdany4bystb3ll7o2yiqb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdany4bystb3ll7o2yiqb.png" alt="Image description" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 2:
&lt;/h4&gt;
&lt;h4&gt;
  
  
  Launching your instance
&lt;/h4&gt;

&lt;p&gt;Enter the name of your web server and choose the Amazon Machine Image (AMI) of your choice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzc8k61w3uyomaoslkg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzc8k61w3uyomaoslkg9.png" alt="Image description" width="800" height="366"&gt;&lt;/a&gt;&lt;br&gt;
If you don't have a key pair, you can simple create one. A key pair is a security credential that authenticates your access to the instance, usually via SSH. A file will be downloaded to your computer once you hit create key pair. Save that file in a secure folder that you could easily access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faopnr1olnp6rrjqbppd5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faopnr1olnp6rrjqbppd5.png" alt="Image description" width="800" height="382"&gt;&lt;/a&gt;&lt;br&gt;
customize your security group and launch your instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpeclphlt300j8q36kv80.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpeclphlt300j8q36kv80.png" alt="Image description" width="800" height="380"&gt;&lt;/a&gt;&lt;br&gt;
You will receive a confirmation once it is successfully launched.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fplo4ui55ll5j75gfyy87.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fplo4ui55ll5j75gfyy87.png" alt="Image description" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3:
&lt;/h4&gt;
&lt;h4&gt;
  
  
  Connecting to your instance.
&lt;/h4&gt;

&lt;p&gt;They are various ways to connect to your instance, such as Secure Shell (SSH) for macOS or PuTTy on windows, Remote Desktop Protocol(RDP) for Windows instance, EC2 instance connect via the AWS Console, AWS Systems Manager, among others. In this tutorial we will be using EC2 Instance Connect.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: You don't need a key pair when using EC2 instance connect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6icxgmtwz6uc504ytpl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6icxgmtwz6uc504ytpl.png" alt="Image description" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 4:
&lt;/h4&gt;
&lt;h4&gt;
  
  
  Installing a Web Server and deploying a simple HTML page.
&lt;/h4&gt;

&lt;p&gt;Once you have successfully connected to your instance, create a file  that contains commands for installing the web server, copying and setting permissions for the &lt;code&gt;.html&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su

nano &amp;lt;filename.sh&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; upgrade -y

sudo apt -y install apache2

sudo systemctl start apache2

sudo systemctl enable apache2

echo "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;Yay, you did it!&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;" &amp;gt; &amp;lt;file_path&amp;gt;/index.html

sudo cp &amp;lt;file_path&amp;gt;/index.html /var/www/html/index.html

sudo chown -R www-data:www-data /var/www/html

sudo chmod -R 775 /var/www/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the file is executable then run your script and replace  with your actual path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -l

chmod +x &amp;lt;filename.sh&amp;gt;

./&amp;lt;filename.sh&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 4:
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Testing!
&lt;/h4&gt;

&lt;p&gt;Once you have run your script and received no error messages, navigate back to the AWS Console, copy the IP address of the instance, and open it in your browser. It should display the page below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2dhcda752dpq9b4akt3r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2dhcda752dpq9b4akt3r.png" alt="Image description" width="800" height="549"&gt;&lt;/a&gt;&lt;br&gt;
Congratulations on launching your first EC2 instance!&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;By following these steps, you have successfully launched an EC2 instance, connected to it, installed a web server, and deployed a simple web page. This process provides the foundation for hosting websites or applications on AWS, offering scalability and flexibility for your projects.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ec2</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Understanding The Basic Syntax Of A Dockerfile.</title>
      <dc:creator>Stephanie Albert</dc:creator>
      <pubDate>Tue, 12 Mar 2024 21:23:07 +0000</pubDate>
      <link>https://dev.to/stefanie-a/understanding-the-basic-syntax-of-a-dockerfile-4c6m</link>
      <guid>https://dev.to/stefanie-a/understanding-the-basic-syntax-of-a-dockerfile-4c6m</guid>
      <description>&lt;p&gt;This article will help you understand the basic commands for creating a Dockerfile which you will use when containerizing different applications and also highlight the benefits of a Dockerfile. Whether you are new to Docker or not, this article will provide valuable information and tips when working with a Dockerfile with different programming languages like Python, Go, Node.Js, Rust, PHP, e.t.c. You will also see how to use the docker init command which initializes the creation of Dockerfiles, compose.yaml and other resources that simplifies the process of configuring Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Dockerfile?
&lt;/h3&gt;

&lt;p&gt;A Dockerfile is a script file that contains instructions or commands for building a docker image. The Dockerfile provides instructions to the Docker engine on how to assemble an image. It includes instructions for installing dependencies, copying files, setting environment variables, and configuring the container. It uses a simple, easy-to-read syntax that can be created and edited with any text editor. Once a Dockerfile has been created, it can be used to build an image using the docker build command. The resulting image can then be run as a container using docker run command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is a Dockerfile necessary?
&lt;/h3&gt;

&lt;p&gt;Dockerfiles enable faster, more efficient, consistent deployment processes for applications. It is necessary and beneficial for several reasons when working with Docker and containerized applications such as:&lt;br&gt;
Reproducibility: Dockerfiles provide a clear and reproducible set of instructions for building a Docker image. This helps ensure consistency across different environments, making it easier to share and deploy applications with the confidence that they will behave the same way everywhere.&lt;/p&gt;

&lt;p&gt;Version Control: Dockerfiles can be version-controlled along with the source code of an application. This allows teams to track changes to the build process and easily roll back to previous versions if needed. It enhances collaboration and provides a history of how the application's environment has evolved.&lt;/p&gt;

&lt;p&gt;Dependency Management: Dockerfiles explicitly list the dependencies and configuration needed for an application to run. This includes base images, system libraries, runtime environments, and any other software dependencies. This makes it easy to understand and manage the software stack of an application.&lt;/p&gt;

&lt;p&gt;Efficient Builds: Docker images are built in layers, and Dockerfile instructions contribute to these layers. When a change is made in the codebase or dependencies, only the affected layers need to be rebuilt, making the build process more efficient and faster.&lt;/p&gt;

&lt;p&gt;Isolation: Dockerfiles encapsulate the configuration of an application, making it isolated from the underlying host system. This isolation helps avoid conflicts with other applications or dependencies on the host and ensures that the application runs consistently, regardless of the host environment.&lt;/p&gt;

&lt;p&gt;Automation: Dockerfiles allow for the automation of the containerization process. Continuous Integration (CI) and Continuous Deployment (CD) pipelines can use Dockerfiles to build and deploy applications automatically. This automation streamlines the development and deployment workflows, reducing the chance of manual errors.&lt;/p&gt;

&lt;p&gt;Portability: Dockerfiles contribute to the portability of applications. Since they define the entire environment needed for an application, Docker images created from these Dockerfiles can run consistently on any system that supports Docker. This portability simplifies deployment across different environments, from development to production.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to create a Dockerfile?
&lt;/h3&gt;

&lt;p&gt;The fundamental Dockerfile command remains consistent but the content and structure varies across different programming languages and technology stack. The basic structure of a Dockerfile is based on a set of simple instructions, such as "FROM", "WORKDIR", "RUN", "COPY", "EXPOSE", "ENV". Each instruction adds a new layer to the image and each layer includes the instructions specified in the previous layer. The final image is a result of all the instructions specified in the Dockerfile.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Create a file called Dockerfile, use any text editor of your choice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;FROM: A dockerfile always starts by importing the base image using this keyword.&lt;/p&gt;

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

From &amp;lt;image&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;WORKDIR: this sets the working directory. This means that any instructions that are run in the container will be executed inside the specified directory.&lt;/p&gt;

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

WORKDIR &amp;lt;directory&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;COPY: the COPY instruction is used to copy files or directories from the host machine into the container current working directory.&lt;/p&gt;

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

COPY &amp;lt;src&amp;gt; &amp;lt;dst&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you want to copy all the files from the host current directory to the container's current directory use:&lt;/p&gt;

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

COPY . .


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The first "." represents the source directory on the host machine and the second "." represents the destination directory within the container.&lt;/p&gt;

&lt;p&gt;RUN: use the run command to execute commands during the image build process. It is used to install necessary packages, run build scripts, e.t.c.&lt;/p&gt;

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

RUN &amp;lt;command&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;CMD: this specifies the specific command to run when a container is started.&lt;/p&gt;

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

CMD ["executable","param1","param2",…]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;ENV: this instruction sets environment variables inside the container which will be available during build time as well as in a running container(image).&lt;/p&gt;

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

ENV MY_VAR=my_value.


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;EXPOSE: this command informs docker that the port the container listens to during run time. It is more of a documentation, it doesn't publish the port.&lt;/p&gt;

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

EXPOSE 5000


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Apart from the commands listed above, there are many others like ENTRYPOINT, ARG, VOLUME, USER, LABEL, e.t.c which are also used to create a Dockerfile but we focused on the basics.&lt;/p&gt;

&lt;p&gt;Sample of a Dockerfile for a Flask App:&lt;/p&gt;

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

FROM python:3.12-slim

EXPOSE 5000

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt 

WORKDIR /app
COPY . /app

CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  What is Docker Init?
&lt;/h3&gt;

&lt;p&gt;Docker init is a CLI command that helps you initialize Docker resources in your projects. It walks you through the creation of Dockerfiles, compose.yaml, .dockerignore files and so on based on your project's requirements. This helps to save time and reduce complexity when configuring Docker for your projects.&lt;/p&gt;
&lt;h3&gt;
  
  
  How to use Docker init?
&lt;/h3&gt;

&lt;p&gt;Using Docker init is easy, after installing it, go to the directory of your project where you want to set up Docker.&lt;br&gt;
Create a basic flask app:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

from flask import Flask

app = Flask(__name__)

@app.route('/')
def docker():
     return "Dockerfile Tutorial"

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then in your terminal run the docker init command:&lt;/p&gt;

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

docker init


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Docker init command will scan your project and ask you to choose the template that best fits your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferpv6fjhwvcbgw3j6j3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferpv6fjhwvcbgw3j6j3o.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After docker init is completed, you may need to modify the created files and tailor them to your projects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmr1d0kripo0aqdrdzl6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmr1d0kripo0aqdrdzl6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note if any of the files exist, a prompt will appear and provide a warning as well as an option to overwrite all the files. You can't recover an overwritten file.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's see what the auto-generated Dockerfile looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgha44dayuvbo4960s8x0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgha44dayuvbo4960s8x0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Creating a Dockerfile can be useful in the automation project or in development as it makes it easy to manage dependencies and system requirements for our application. Instead of having to worry about ensuring that your application has the correct versions of libraries and dependencies installed on the host system, we can easily specify them in the Dockerfile and they will be included in the container image.&lt;br&gt;
This makes it easy to manage and control the dependencies of your application, and it also makes it easy to test your application on different environments. The Docker init command also helps to save time and effort and also write better Dockerfiles, but I would recommend you to cross check the configuration before you push through with it.&lt;br&gt;
Hope you like the article. Thanks for reading!&lt;/p&gt;

&lt;p&gt;Source code: &lt;a href="https://github.com/Stefanie-A/docker-app-template.git" rel="noopener noreferrer"&gt;https://github.com/Stefanie-A/docker-app-template.git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>container</category>
      <category>python</category>
    </item>
    <item>
      <title>How To Deploy A Flask App On Digitalocean</title>
      <dc:creator>Stephanie Albert</dc:creator>
      <pubDate>Sat, 20 Jan 2024 19:19:41 +0000</pubDate>
      <link>https://dev.to/stefanie-a/how-to-deploy-a-flask-app-on-digitalocean-3ib7</link>
      <guid>https://dev.to/stefanie-a/how-to-deploy-a-flask-app-on-digitalocean-3ib7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Flask is a python framework for building web applications. It’s a popular choice for building web apps because of its simplicity and flexibilty. Gunicorn(Green unicorn) is a Python WSGI HTTP server for unix. It acts as a middle layer which receives requests sent to the Web server from a client  and forwards them to the Python app. Nginx on other hand is a Web server and reverse proxy which helps in load balancing, caching and handling static files. Docker simplifies your deployment process, allowing you to package your application and its dependencies into a single container.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will deploy a flask app to a digitalocean droplet from an existing github repository, utilizing Gunicorn and Nginx and also containerize the app with Docker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
To follow this tutorial, we will need the following:&lt;br&gt;
Digitalocean account, required for deploying the application.&lt;br&gt;
Git to clone the repository.&lt;br&gt;
Gunicorn installed for running the web applications.&lt;br&gt;
Nginx installed, following steps from Nginx Documentation.&lt;br&gt;
Docker installed for creating and running your container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1- Creating a Droplet and Installing Gunicorn
&lt;/h2&gt;

&lt;p&gt;We will be deploying our application on digitalocean so you need to create an account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a droplet on digitalocean.
&lt;/h3&gt;

&lt;p&gt;The first step is to choose any region of your choice, image for your server, select a CPU option and an authentication method.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr0vu0s8tnsrc33ufq680.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr0vu0s8tnsrc33ufq680.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: SSH into your droplet console, install python and clone your github repository of your existing flask application.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw6sj8ovht5wtolsh5rqb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw6sj8ovht5wtolsh5rqb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

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

sudo apt update
sudo apt install python3 python3-pip python3-venv 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will also install the venv module.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flec5tgzzgwoqzcrkrm7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flec5tgzzgwoqzcrkrm7b.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Clone the Github repo&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft4r4q2h490mdubii75o7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft4r4q2h490mdubii75o7.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Navigate into your github repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73mq7ig51kn89vhsg0rm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73mq7ig51kn89vhsg0rm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create a python virtual environment on your server.(Optional)
&lt;/h3&gt;

&lt;p&gt;Creating a python virtual environment is totally optional. It is used when you have multiple python versions installed on your server.&lt;br&gt;
Make a new directory and navigate into it.&lt;/p&gt;

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

mkdir venv
cd venv


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now create a virtual environment and activate it as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkaugl4u06pepqrvyemgs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkaugl4u06pepqrvyemgs.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Your prompt will change to indicate that you are operating inside a virtual environment.&lt;br&gt;
To deactivate simply execute the command below(optional):&lt;/p&gt;

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

deactivate


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Step 4: Install Gunicorn
&lt;/h3&gt;

&lt;p&gt;We need to install Gunicorn which will serve our flask app and we also install all requirements necessary for your Flask app from the requirements.txt in the repository.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folhecmw9g42o6vc295hq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folhecmw9g42o6vc295hq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

pip install -r requirements.txt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We will now start your the flask app using the following command.&lt;/p&gt;

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

python app.py


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feq5a1z0zxnap66pthkmv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feq5a1z0zxnap66pthkmv.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
 Visit your server’s ip address on your browser.(&lt;a href="http://your_server_ip:port" rel="noopener noreferrer"&gt;http://your_server_ip:port&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwmhcl1d6hrnnaqq4x9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwmhcl1d6hrnnaqq4x9z.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
If we close our terminal, the flask app will stop running. To keep it running in the background, we need Gunicorn as a daemon. It operates as a background process, detaching from the terminal. If you close the terminal or logout without destroying the server the app won’t stop running because daemon continues to run in the background.&lt;/p&gt;

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

gunicorn -b 0.0.0.0:8000 app:app --daemon


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Great job! You have successfully deployed your Flask app using Gunicorn.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2-Setting up and Configuring Nginx
&lt;/h2&gt;

&lt;p&gt;Now that you have completed the first part of deploying your Flask app and making it accessible with Gunicorn a web server gateway interface(WSGI) for python applications on your web browser, the next part is to set up Nginx which is a web server for reserve proxy(a server that sits between the client devices and a backend server) handling request from clients and forwarding them to the appropriate backend server and takes the response back to the clients.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Nginx
&lt;/h3&gt;

&lt;p&gt;Ngnix should be automatically registered as a systemd service and should be running.&lt;/p&gt;

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

sudo apt install nginx -y


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To check the status of your nginx if it is running or not use the following command:&lt;/p&gt;

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

sudo systemctl status nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If it is not running then execute this command:&lt;/p&gt;

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

sudo systemctl start nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmruybzczxyrrwj6mabsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmruybzczxyrrwj6mabsp.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Then you are good to go. For visual verification that everything is working properly, visit your server ip address again on your brower(&lt;a href="http://your_server_ip" rel="noopener noreferrer"&gt;http://your_server_ip&lt;/a&gt;), and you should see the Nginx default welcome page.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqhp6qfuhwxx8lveoug2d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqhp6qfuhwxx8lveoug2d.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2:  Configuring Nginx
&lt;/h3&gt;

&lt;p&gt;Nginx configuration usually lives in the /etc/nginx directory with the Nginx configuration files ending with .conf extension inside. Navigate into this directory and list all the files:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuz6a83lq43lkskv9f3i5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuz6a83lq43lkskv9f3i5.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Let’s move the contents of the nginx.conf file into a new file and create a new configuration file for learning purposes to avoid editing the original nginx.conf file.&lt;/p&gt;

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

#rename file
sudo mv nginx.conf nginx.conf.backup

#create new file
touch nginx.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Open your newly created nginx.conf file using any text editor of your choice and write your new configurations. I will be using nano throughout this tutorial. :&lt;/p&gt;

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

sudo nano /etc/ngnix/nginx.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

events {

}

http {

    server {

        listen 80;
        server_name tutorial.test;

        return 200 "Bonjour, mon ami!\n";
    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Step 3: Validate and reload the configuration file
&lt;/h3&gt;

&lt;p&gt;Validate your configuration file to check for any syntax error. If you have a syntax error this command below will let you know.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo nginx -t


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwwjbtb19alcurmii6vgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwwjbtb19alcurmii6vgt.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The next thing you have to do is to instruct nginx to reload the configuration file:&lt;/p&gt;

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

sudo nginx -s reload


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxzik05j7hycyifbczqaa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxzik05j7hycyifbczqaa.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Once you have reloaded the file, simply reload your web browser again.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypxoz98grwf1b7lb0te3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypxoz98grwf1b7lb0te3.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Congratulations on getting this far!&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3- Containerize your App With Docker
&lt;/h2&gt;

&lt;p&gt;One of the benefits about containerising your application(s) is that it allows you to package all dependencies, configuration, system tools and runtime necessary for your application into a single container and deploy it across different environments. In this tutorial we will use docker basic syntax to carry this out.We will only be taking a high level overview of how to use Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Docker
&lt;/h3&gt;

&lt;p&gt;The first step is to install docker, enable it and start it:&lt;/p&gt;

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

sudo apt install docker.io
sudo systemctl enable docker
sudo systemctl start docker


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 2: Create a dockerfile
&lt;/h2&gt;

&lt;p&gt;Let's create a dockerfile which is used to build Docker Images. It is a simple text file that consists of a set of instructions or commands that is executed by an automated build process in steps from top to bottom. The dockerfile can be modified to meet your needs.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo touch Dockerfile 
sudo nano Dockerfile


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

FROM python:3.10

WORKDIR /app
COPY requirements.txt /app/

RUN python -m venv venv
Env PATH="/app/venv/bin:$PATH"

RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 80  

CMD ["python3.10", "app.py"]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 3: Build and Run
&lt;/h2&gt;

&lt;p&gt;Now that your dockerfile is ready, it is time to build an image and run it.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker build -t tutorial .
docker run -d -p 8080:8000 tutorial


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftb86xwn7231kyiava9k2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftb86xwn7231kyiava9k2.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Nice job! Your app has successfully been containerized.&lt;/p&gt;

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

&lt;p&gt;In this tutorial, you learned how to deploy your Flask app and containerize it with docker. We first cloned an existing Flask App from Github into a Digitalocean droplet. Gunicorn was installed which was used to create a python web server gateway interface and also Nginx for reverse proxy which could also be used for caching and load balancing. Docker was used to containerize the app making it possible for you to deploy it in any environment without installing any dependency.&lt;/p&gt;

&lt;p&gt;Deployment is essential in making your app operational and accessible by users to interact with it. It is an important step  in software deployment life cycle. Through deployment, your app becomes available on servers or cloud platforms, allowing users to access, experience, and benefit from its features, ultimately realizing the software's intended purpose. It is the bridge that connects the development phase to the end-users, ensuring that the app is ready for real-world usage, feedback, and continuous improvement. &lt;/p&gt;

&lt;p&gt;I hope you find this article helpful. Thank you🙂.&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>docker</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
