<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashmat Parwany on Medium]]></title>
        <description><![CDATA[Stories by Ashmat Parwany on Medium]]></description>
        <link>https://medium.com/@parwanas?source=rss-afa9d5ee98c1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8zdIbvXoj9B1nwENkRldjw.jpeg</url>
            <title>Stories by Ashmat Parwany on Medium</title>
            <link>https://medium.com/@parwanas?source=rss-afa9d5ee98c1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:11:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parwanas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dockerizing Your Python Project: A Simple Guide]]></title>
            <link>https://medium.com/@parwanas/dockerizing-your-python-project-a-simple-guide-693bc2eab3a3?source=rss-afa9d5ee98c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/693bc2eab3a3</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[project-boilerplate]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ashmat Parwany]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 17:02:30 GMT</pubDate>
            <atom:updated>2023-09-03T17:02:30.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*D0dUEJDv2O-upYavBLJvPQ.png" /></figure><p>Ever wondered how to package a Python app so it can run just about anywhere? Enter Docker, the solution that brings consistency and portability to the mix. This guide is all about making these two tech work together. Let’s jump in!</p><h3>Why Bother with Docker?</h3><p>Before we dive into the ‘how’, here’s the ‘why’ in a nutshell:</p><ol><li>Consistency: Docker’s like that reliable friend. It ensures your app behaves the same whether it’s on your local machine or in a cloud setup.</li><li>No Mess: Think of Docker containers as tidy compartments. One container’s contents don’t interfere with another’s.</li><li>Scale It Up: When it’s time to grow, Docker lets you scale your app, be it on your own computer or on a powerhouse server in the cloud.</li></ol><h3>Let’s Get Our Hands Dirty!</h3><p>Here’s a quick look at our project structure:</p><pre>Project_folder<br>|-- docker/ <strong><em>Docker&#39;s toolkit</em></strong><br>    |-- Dockerfile<br>    |-- docker-compose.yml<br>    |-- requirements.txt<br>|-- app/ <strong><em>This is where our Python code resides</em></strong><br>    |-- main.py</pre><p>Now we have an overall view of how the project is structured let’s define the content of each file inside the docker folder</p><ol><li><strong>Dockerfile</strong></li></ol><pre># Use the official Python 3.11.5 image as the base<br>FROM python:3.11.5<br><br># Set a working directory<br>WORKDIR /usr/src/app<br><br># Copy the requirements file into the container<br>COPY docker/requirements.txt .<br><br># Install Python dependencies<br>RUN pip install --no-cache-dir -r requirements.txt<br><br># Copy the rest of the application code into the container<br>COPY app/ /usr/src/app/<br><br># The command to run when the container starts<br>CMD [&quot;python&quot;, &quot;./main.py&quot;]</pre><p>Here in a nutshell we:</p><ul><li>We begin declaring the Python image.</li><li>Define our workspace inside the container.</li><li>Copy over our requirements and install them.</li><li>Transfer our Python app into the container.</li><li>Specify the command to run our app.</li></ul><p><strong>2. All About Docker Compose</strong></p><p>This file acts as our orchestrator:</p><pre>version: &#39;3&#39;<br>services:<br>  app:<br>    build:<br>      context: ..<br>      dockerfile: docker/Dockerfile<br>    ports:<br>      - &#39;5000:5000&#39; # For accessing our Python app if needed</pre><p>It helps us:</p><ul><li>Set up the environment for our Docker operations.</li><li>Point to our Dockerfile.</li><li>Make the root folder of the project the context</li><li>Expose our Python app on port 5001.</li></ul><p>If you ever need to add another image let’s say of a MongoDB or anything else it would be under <strong>services.</strong></p><p><strong>3. Dependencies</strong></p><p>The requirements file contain all the dependencies that will be needed inside the project, as defined below you have to put the module name and version.</p><pre>requests==2.26.0</pre><h3>How do we run it?</h3><p>Running it is very simple:</p><ol><li>Ensure <strong>Docker</strong> &amp; <strong>Docker Compose</strong> are installed.</li><li>Navigate to your project directory.</li><li>Kick things off with docker-compose up.</li></ol><p>Voila! Your Python application is now humming along inside its Docker container on port 5000, what can be recommended would be to use a “<strong><em>script.sh”</em></strong> for it to do all the instructions at once.</p><h3>That’s a Wrap!</h3><p>Docker brings a new layer of convenience and flexibility to your Python applications. Give it a whirl and experience the difference! 🚀</p><p>Just a note, this is my inaugural article. Thanks for reading till the end. There’s more content in the pipeline, so stay tuned for more insights and explorations. Cheers! 🎉📝</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=693bc2eab3a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>