<?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: Alan Njogu</title>
    <description>The latest articles on DEV Community by Alan Njogu (@njoguu).</description>
    <link>https://dev.to/njoguu</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%2F911534%2F6aa78764-65cd-4bb9-84bb-6c1597f22824.png</url>
      <title>DEV Community: Alan Njogu</title>
      <link>https://dev.to/njoguu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/njoguu"/>
    <language>en</language>
    <item>
      <title>Running a Python Script on Google Cloud in 2023: A Step-by-Step Guide</title>
      <dc:creator>Alan Njogu</dc:creator>
      <pubDate>Wed, 31 May 2023 15:47:30 +0000</pubDate>
      <link>https://dev.to/njoguu/running-a-python-script-on-google-cloud-in-2023-a-step-by-step-guide-272k</link>
      <guid>https://dev.to/njoguu/running-a-python-script-on-google-cloud-in-2023-a-step-by-step-guide-272k</guid>
      <description>&lt;p&gt;&lt;a href="https://go.fiverr.com/visit/?bta=736111&amp;amp;nci=9933" rel="sponsored"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YHMcly6C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://fiverr.ck-cdn.com/tn/serve/%3Fcid%3D26106769" width="728" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As the demand for scalable and efficient cloud computing solutions continues to grow, Google Cloud Platform (GCP) remains a popular choice among developers. In this blog post, we will explore how to run a Python script on Google Cloud in 2023. Whether you are a beginner or an experienced developer, this step-by-step guide will help you leverage the power of GCP for your Python applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;p&gt;Before we dive into the process, make sure you have the following prerequisites in place:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Google Cloud Platform account: &lt;a href="https://console.cloud.google.com/freetrial"&gt;Sign up&lt;/a&gt; for GCP if you don't already have an account.&lt;/li&gt;
&lt;li&gt;Python installed on your local machine: Ensure you have Python installed, preferably version 3.x.&lt;/li&gt;
&lt;li&gt;A basic understanding of the command line interface (CLI).&lt;/li&gt;
&lt;li&gt;A basic understanding of Git.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure you have a repository set up that contains the Python scripts you want to run on Google Cloud. This could be a repository hosted on a version control platform like GitHub. Having a repository allows you to easily clone the code onto your VM Instance and execute the Python scripts seamlessly. If you haven't set up a repository yet, take some time to create one and ensure it contains the necessary Python scripts you want to deploy.&lt;/p&gt;

&lt;p&gt;Let's get started with the process:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Set up a Google Cloud project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Log in to the &lt;a href="//console.cloud.google.com"&gt;Google Cloud Console&lt;/a&gt; using your GCP account credentials.&lt;/li&gt;
&lt;li&gt;Create a new project or select an existing one from the project dropdown menu.&lt;/li&gt;
&lt;li&gt;Take note of your project ID, as it will be required in later steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1VEm794m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtvtm0wfnesszw8bafoc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1VEm794m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtvtm0wfnesszw8bafoc.jpg" alt="Select Project" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Enable the necessary APIs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the Google Cloud Console, navigate to the APIs &amp;amp; Services section.&lt;/li&gt;
&lt;li&gt;Click on "Library" in the left navigation menu.&lt;/li&gt;
&lt;li&gt;Search for "Compute Engine API" and enable it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Create a VM Instance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click on the hamburger menu in the top-left corner of the console, and select "Compute Engine."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3G_g59Lm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2tioxjljrxuzph3peml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3G_g59Lm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2tioxjljrxuzph3peml.png" alt="Navigate to the Compute Engine section" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Compute Engine section, click on the "CREATE INSTANCE" button to start creating a new VM instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1PN5OOzZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xy32qy5ofs2hu5umrnee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1PN5OOzZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xy32qy5ofs2hu5umrnee.png" alt="Create a new VM instance" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fill in the necessary details to configure your VM instance. Provide a unique name for your VM instance and leave every other setting on default.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VVwGTry0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts2zjjd0zzo5tfntarg8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VVwGTry0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts2zjjd0zzo5tfntarg8.png" alt="Configure the VM instance settings" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scroll down and click “CREATE”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gEMKnp6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yce8wxe6r5vgxj2g3xer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gEMKnp6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yce8wxe6r5vgxj2g3xer.png" alt="Configure the VM instance settings" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the VM instance is created, you can monitor its status, connect to it via SSH, manage its network settings, and perform various other actions from the Compute Engine section in the Google Cloud Console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cIl3CWn4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlspifbfhlpwu2jnbjkm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cIl3CWn4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlspifbfhlpwu2jnbjkm.jpg" alt="VM Instance Created" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://go.fiverr.com/visit/?bta=736111&amp;amp;nci=8595" rel="sponsored"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--urm8Gxmg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://fiverr.ck-cdn.com/tn/serve/%3Fcid%3D26106852" width="728" height="96"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Connect to the VM instance using SSH
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click on the "SSH" button next to the VM instance you want to access. This will open a browser-based SSH terminal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_ocq9ge7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zptjkrpu8bk3ixbomd0z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_ocq9ge7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zptjkrpu8bk3ixbomd0z.jpg" alt="Connecting to the VM instance" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Installing Software and Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;We need to install necessary software and dependencies .i.e. Python, Git, Tmux and pip.&lt;/li&gt;
&lt;li&gt;First, you need to update the package manager before installing any software. It's a good practice to update the package manager on your VM instance. Run the following command: &lt;code&gt;sudo apt update&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jsKmJJIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdnezyg80r16cia8xbpr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jsKmJJIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdnezyg80r16cia8xbpr.png" alt="Updating package manager" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By default, many Linux distributions come with Python preinstalled. However, if Python is not already installed or you want to install a specific version, you can use the package manager to install it. Run the following command to install Python 3: &lt;code&gt;sudo apt install python3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Pip is the package installer for Python. To install pip, use the following command: &lt;code&gt;sudo apt install python3-pip&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lD9vJea9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsiawdatba7p8a4f19zf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lD9vJea9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsiawdatba7p8a4f19zf.png" alt="Installing Python and Pip" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To install Git, use the following command: &lt;code&gt;sudo apt install git&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OrB1x_o5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aal2v20u1176pmg8qd78.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OrB1x_o5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aal2v20u1176pmg8qd78.png" alt="Installing Git" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install tmux. Tmux is a terminal multiplexer that allows you to run multiple terminal sessions within a single window. Install tmux using the following command: &lt;code&gt;sudo apt install tmux&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rTaoq3hU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5isuuibn4rkt8v64fv2v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rTaoq3hU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5isuuibn4rkt8v64fv2v.png" alt="Install Tmux" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Cloning the repository
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Clone the repository of the project you want to run using &lt;code&gt;git clone &amp;lt;repository_url&amp;gt;&lt;/code&gt;providing the repository URL. Replace  with the actual URL of the repository you want to clone. This will create a local copy of the repository on your VM instance.&lt;/li&gt;
&lt;li&gt;Once the cloning process is complete, navigate to the cloned repository directory using the cd command. For example: &lt;code&gt;cd my-repository&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hjH2RvP6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mx8cpooebvm33aks6e6c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hjH2RvP6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mx8cpooebvm33aks6e6c.png" alt="Cloning the repository" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Replace '&lt;strong&gt;my-repository&lt;/strong&gt;' with the name of the cloned repository directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Run the Python script
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;After navigating to the directory containing the Python file you want to run, use the python3 command to execute the file by running this command: &lt;code&gt;python3 my_script.py&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Replace my_script.py with the name of your Python script.&lt;/p&gt;

&lt;p&gt;Note: Before running the Python script, make sure you have any necessary dependencies or requirements installed on your VM instance. You can use &lt;strong&gt;pip&lt;/strong&gt; to install the required packages if needed. If you have a number of dependencies, you can run &lt;code&gt;pip install -r requirements.txt&lt;/code&gt; to install them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m_ywbEB6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8djbdhhi8q5vxq0z2v3l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m_ywbEB6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8djbdhhi8q5vxq0z2v3l.png" alt="Install requirements" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 8: Monitor the script's output
&lt;/h3&gt;

&lt;p&gt;Once you execute the Python script, monitor the terminal output to ensure it runs successfully. The script may produce some output or perform certain actions based on its functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 9: *&lt;em&gt;Optional *&lt;/em&gt;- Detach the process using tmux (recommended for long-running scripts)
&lt;/h3&gt;

&lt;p&gt;If your Python script takes a long time to complete or you want to keep it running 24/7 in the background, it's recommended to use a terminal multiplexer like &lt;a href="https://linuxize.com/post/getting-started-with-tmux/"&gt;tmux&lt;/a&gt;. This allows you to detach the process and keep it running even if you disconnect from the SSH session.&lt;/p&gt;

&lt;p&gt;To use tmux, run the following command to start a new tmux session: &lt;code&gt;tmux new -s mysession&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tGAuwegK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/et4dltgjikm0gg1x49pf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tGAuwegK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/et4dltgjikm0gg1x49pf.png" alt="Start a new Tmux session" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Replace '&lt;strong&gt;mysession&lt;/strong&gt;' with a suitable session name of your choice.&lt;/p&gt;

&lt;p&gt;Inside the tmux session, navigate to the directory containing the Python script and execute it as mentioned in Step 7. Once the script starts running, you can detach the tmux session by pressing 'Ctrl-b' followed by 'd'. This will detach the session and return you to the normal SSH terminal.&lt;/p&gt;

&lt;p&gt;To reattach to the tmux session in the future, use the following command: &lt;code&gt;tmux a -t mysession&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Replace '&lt;strong&gt;mysession&lt;/strong&gt;' with the name of your tmux session.&lt;/p&gt;




&lt;p&gt;Running a Python script on Google Cloud in 2023 opens up a world of possibilities for developers and businesses alike. With the power and flexibility of Google Cloud's infrastructure, you can easily deploy and scale your Python applications to meet the demands of your users. In this step-by-step guide, we covered the process of creating a VM instance, connecting to it, installing Python, pip, Git, and tmux, and running a Python file from a cloned repository.&lt;/p&gt;

&lt;p&gt;As the world of technology continues to evolve, Google Cloud remains at the forefront of innovation, providing developers with powerful tools and services to bring their Python applications to life. So, go ahead and unleash the full potential of your Python scripts on Google Cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://go.fiverr.com/visit/?bta=736111&amp;amp;nci=16826"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7ztC3CZ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://fiverr.ck-cdn.com/tn/serve/%3Fcid%3D26106724" width="320" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>googlecloud</category>
      <category>computeengine</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Setting Up a Great Python Dev Environment with Docker</title>
      <dc:creator>Alan Njogu</dc:creator>
      <pubDate>Sat, 11 Mar 2023 06:15:00 +0000</pubDate>
      <link>https://dev.to/njoguu/setting-up-a-great-python-dev-environment-with-docker-2b01</link>
      <guid>https://dev.to/njoguu/setting-up-a-great-python-dev-environment-with-docker-2b01</guid>
      <description>&lt;p&gt;Are you tired of having to set up your Python development environment every time you start a new project? Docker can help you out! In this post, I will guide you through the process of setting up a Python development environment using Docker, starting with cloning a git repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To be able to follow along, make sure you are using VS Code and you have Git installed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloning the git repo
&lt;/h2&gt;

&lt;p&gt;To get started, clone the git repo for your project. In this case, I am working on &lt;a href="https://github.com/Njoguu/qlipa-API" rel="noopener noreferrer"&gt;q-lipa’s API&lt;/a&gt;. You can do this by running the following command in your terminal:&lt;br&gt;
&lt;code&gt;git clone https://github.com/Njoguu/qlipa-API.git&lt;/code&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%2F8oiqrlhrlrakmndxagbe.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%2F8oiqrlhrlrakmndxagbe.png" alt="Cloning a repo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Environment
&lt;/h2&gt;

&lt;p&gt;First, make sure that you have installed Docker on your machine. Installation instructions can be found on the Docker &lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;website&lt;/a&gt;. I already have it installed.&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%2Fwdzyp1x3wwg9fenxky8o.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%2Fwdzyp1x3wwg9fenxky8o.png" alt="Checking if docker is installed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, navigate to the directory and create a new file called "requirements.txt" to house all the dependencies required for your app. Additionally, create a directory called "src" where the Python files will be stored.&lt;/p&gt;




&lt;p&gt;Create a sample main.py file that will act as a ‘placeholder’ for the app. You can get the code from &lt;a href="https://fastapi.tiangolo.com/tutorial/first-steps/" rel="noopener noreferrer"&gt;FastAPI's Tutorial-Guide&lt;/a&gt;.  &lt;/p&gt;




&lt;p&gt;To use Docker with your project, first create a file named “Dockerfile” in the root directory of the project. Dockerfile typically contains instructions for installing dependencies, copying files into the image, and configuring the environment. Once the Dockerfile is created, it can be used to build a Docker image, which can then be used to run containers with the application inside.&lt;/p&gt;

&lt;p&gt;Next, add the necessary packages for your Dockerfile, at the time this includes Uvicorn and FastAPI, to the requirements.txt file. Once this is done, you can build your Docker image by adding the following code to the Dockerfile.&lt;/p&gt;

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

# Use the latest Python Version as the base image
FROM python:3.12.0a6-slim-buster

# Setup the working directory for the container
WORKDIR /code

# Copy the requirements file to the container
COPY ./requirements.txt ./

# Install the Python dependencies using Python 
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code to the container
COPY ./ ./

# Setup the command to run when the container starts
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]


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

&lt;/div&gt;




&lt;h3&gt;
  
  
  Building the Docker image
&lt;/h3&gt;

&lt;p&gt;Navigate to the repo directory and build the Docker image by running the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker build -t &amp;lt;your-image-name&amp;gt; .&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will build the Docker image for your Python development environment.&lt;/p&gt;




&lt;h3&gt;
  
  
  Running the Docker container
&lt;/h3&gt;

&lt;p&gt;Now that the Docker image has been built, you can run the Docker container and start working on your Python project. &lt;/p&gt;

&lt;p&gt;Run the following command in your terminal:&lt;br&gt;
&lt;code&gt;docker run -d -p 8000:8000 &amp;lt;your-image-name&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command starts the Docker container, maps port 8000 on your local machine to port 8000 in the container, and runs the app.&lt;/p&gt;




&lt;h3&gt;
  
  
  Registering File changes - Using Docker Volumes
&lt;/h3&gt;

&lt;p&gt;This all looks great, but there is a problem. When you change something in the code and refresh the app in the browser, you don’t get the new code/the new changes. This is because the code is in your local machine but the app itself is running inside the container.&lt;/p&gt;




&lt;p&gt;To make the changes and make the app register those changes automatically, we use volumes. &lt;br&gt;
SEE 👉 &lt;a href="https://docs.docker.com/storage/volumes/" rel="noopener noreferrer"&gt;What is a volume?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can do this by making a few changes to what you use to run the docker image. instead use the following code:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d -p 8000:8000 -v $(pwd):/code &amp;lt;your-image-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This code launches a container and maps port 8000 on your local machine to port 8000 in the container. It also mounts the current working directory on  the host machine to the &lt;code&gt;code&lt;/code&gt; directory in the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Note&lt;/strong&gt;: You may run into an error that typically occurs when you are trying to run a Docker command with a repository name that includes uppercase letters. (I’ve right now just learnt Docker repository names must all be lowercase). I found a &lt;a href="https://stackoverflow.com/questions/48522615/docker-error-invalid-reference-format-repository-name-must-be-lowercase" rel="noopener noreferrer"&gt;fix on StackOverflow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you run into the error, use this code:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d -p 8000:8000 -v "$(pwd):/code" &amp;lt;your-image-name&amp;gt;&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;When you run the app successfully, and make changes to the code, the app will automatically register the changes, and they will be displayed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using an IDE in a Docker Container
&lt;/h3&gt;

&lt;p&gt;There is still a problem though. We can’t really code inside the IDE as the IDE does not recognize the dependencies of the app. If you remember, we did not install the dependencies on the local machine, but inside the container. What we actually want is to have this IDE inside the Docker Container.&lt;/p&gt;

&lt;p&gt;To achieve this, you need two VS Code extensions, &lt;strong&gt;Docker&lt;/strong&gt; extension and the &lt;strong&gt;Dev Containers&lt;/strong&gt; extension. Install these two, and then on the bottom left, you should see a little button that when you hover, it says “Open a Remote Window”. Click on it.&lt;/p&gt;

&lt;p&gt;As you will see from the options, there are different ways in which you can connect to a remote container. But in our case, since we have an existing container that is already running in the background, click on “Attach to Running Container” and select the container for the project you are working on.&lt;/p&gt;

&lt;p&gt;This will open up a new instance of VS Code and this lives inside the Docker Container which we created.&lt;/p&gt;

&lt;p&gt;Since this is a whole new environment, you will have to install all necessary extensions again for you to use in your project. In this case, I install the Python extension.&lt;/p&gt;




&lt;p&gt;We can now code!&lt;/p&gt;

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

&lt;p&gt;In this post, I have shown you how to set up a great Python development environment using Docker. By cloning a git repo, building a Docker image, and running the Docker container, using Docker Volumes, using an IDE inside a Docker Container.&lt;/p&gt;

&lt;p&gt;You can easily set up a consistent Python development environment that can be used across projects. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This project will later require multiple containers though, this is where Docker Compose comes in. It is a tool for defining and running multi-container applications. Stay tuned to learn how to set it up!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>docker</category>
      <category>fastapi</category>
    </item>
    <item>
      <title>Streamline Your Job Search: Product Website Launches, product to be Released in the Future.</title>
      <dc:creator>Alan Njogu</dc:creator>
      <pubDate>Fri, 27 Jan 2023 09:23:38 +0000</pubDate>
      <link>https://dev.to/njoguu/streamline-your-job-search-product-website-launches-product-to-be-released-in-the-future-772</link>
      <guid>https://dev.to/njoguu/streamline-your-job-search-product-website-launches-product-to-be-released-in-the-future-772</guid>
      <description>&lt;p&gt;We are thrilled to announce the launch of our website for our Job Search API product!&lt;br&gt;
This is a big step for us as we work towards revolutionizing the job search process for job seekers and companies alike.&lt;/p&gt;

&lt;p&gt;Our website has been designed with user experience in mind, making it easy for you to navigate and find the information you need. It features all the necessary information about our product, including its features.&lt;/p&gt;

&lt;p&gt;We know many of you are eagerly waiting for the product to become available, and we want to assure you that it is in the works. We are working tirelessly and we expect to release the API soon. &lt;/p&gt;

&lt;p&gt;In the meantime, we invite you to explore our website and sign up for our newsletter to stay informed about the latest updates. We are confident that our Job Search API will be a game-changer and we can’t wait for you to experience it.&lt;/p&gt;

</description>
      <category>api</category>
      <category>release</category>
      <category>development</category>
    </item>
    <item>
      <title>jikAPI - The #1 Job Search API in Kenya.</title>
      <dc:creator>Alan Njogu</dc:creator>
      <pubDate>Sun, 22 Jan 2023 00:10:39 +0000</pubDate>
      <link>https://dev.to/njoguu/jikapi-the-1-job-search-api-in-kenya-3kb4</link>
      <guid>https://dev.to/njoguu/jikapi-the-1-job-search-api-in-kenya-3kb4</guid>
      <description>&lt;p&gt;Excited to announce that the development of a Job Search API -  &lt;strong&gt;jikAPI&lt;/strong&gt; - a powerful tool for all job seekers in Kenya, is underway.&lt;/p&gt;

&lt;p&gt;The API allows users to search for job opportunities that have been recently posted by employers in Kenya. It provides a simple and easy-to-use interface for users to find the perfect job for them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;jikAPI&lt;/strong&gt; offers a variety of search parameters for users to filter their results by. Users can search for jobs by keyword, location, job category, etc.&lt;/p&gt;

&lt;p&gt;One of the most useful features of the Job Search API is its real-time updates. As soon as a new job is posted, it is added to the API's database and becomes searchable by users. This means that users will never miss out on a new job opportunity again.&lt;/p&gt;

&lt;p&gt;The API will also provide detailed information about each job listing, such as the job title, company, location, and a link to the job listing on the employer's website. This makes it easy for users to apply for jobs they are interested in.&lt;/p&gt;

&lt;p&gt;Searching for a job can be a stressful and time-consuming process. That's why &lt;strong&gt;jikAPI&lt;/strong&gt; was created to make the process as easy as possible. With the API, web applications that use it can help their users quickly and easily find job opportunities that are relevant to them, saving them time and effort.&lt;/p&gt;

&lt;p&gt;Stay tuned for updates on its progress and release date!&lt;/p&gt;

</description>
      <category>github</category>
      <category>discuss</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
