<?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 Dhafin Almas on Medium]]></title>
        <description><![CDATA[Stories by Dhafin Almas on Medium]]></description>
        <link>https://medium.com/@fhinnn?source=rss-529ce5686467------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PGCK0nYySFmLXFwPde9O7A.jpeg</url>
            <title>Stories by Dhafin Almas on Medium</title>
            <link>https://medium.com/@fhinnn?source=rss-529ce5686467------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:56:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fhinnn/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[No Web Dev Skills? Gradio Turns Your AI models into a Cool Web App in Minutes!]]></title>
            <link>https://fhinnn.medium.com/no-web-dev-skills-gradio-turns-your-ai-models-into-a-cool-web-app-in-minutes-8a6431a6fbd9?source=rss-529ce5686467------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a6431a6fbd9</guid>
            <dc:creator><![CDATA[Dhafin Almas]]></dc:creator>
            <pubDate>Fri, 09 May 2025 17:47:03 GMT</pubDate>
            <atom:updated>2025-05-09T17:47:03.514Z</atom:updated>
            <content:encoded><![CDATA[<h3>No Web Dev Skills? Gradio Turns Your AI into a Cool Web App in Minutes!</h3><p>A quick and easliy way to create interfaces for your machine learning models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*OaV5eb_DRNIJQal_B7-YDQ.jpeg" /></figure><p>I once ran into an issue where I was told to deploy the model as web, but I was also told to create an interface before doing so. Then I started looking for an alternative solution and finally found a python library called Gradio.</p><p>Gradio is an open-source library used to easily create web-based user interfaces for machine learning and data science applications. With gradio you can create an interface for a model or even multiple models in one interface.</p><h3>Requirements</h3><p>Some things that must be prepared are make sure you already have <strong>python</strong>, <strong>pip</strong>, and <strong>venv </strong>on your computer. If you already have the necessary requirements, you can try following the steps in the implementation section below.</p><h3><strong>Implementation</strong></h3><p>So, here we will try to use gradio to create a model interface. Here are the implementation steps:</p><ol><li>Install Gradio package using pip. You can try with Jupyter Notebook, VS Code, or Google Colab.</li></ol><pre>pip install gradio</pre><p>2. Build interface with Gradio in python. Here’s a simple example of using Gradio.</p><pre>import gradio as gr<br><br><br>def greet(name):<br>    return &quot;Hello &quot; + name + &quot;!&quot;<br><br><br>demo = gr.Interface(fn=greet, inputs=&quot;textbox&quot;, outputs=&quot;textbox&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    demo.launch()</pre><p>You need to import the gradio module, define a function that processes input into output (for example, greet() function), and then load function using gr.Interface.</p><blockquote>Gradio turn any AI model into a user-friendly web app by simply wrapping it in a Python function and connecting it to an web interface.</blockquote><p>In addition, we can also specify inputsand outputswith various types, such as textbox, checkboxes, numbers, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hOdz3tjmUE2tT2uRttbzMw.png" /><figcaption>By default it exposes to port 7860 and binds to the Localhost IP (127.0.0.1).</figcaption></figure><p>3. Customize your interface with Blocks Layout. For Example,</p><pre>import gradio as gr<br><br>def greet(name):<br>    return &quot;Hello &quot; + name + &quot;!&quot;<br><br>def square(num):<br>    return num ** 2<br><br>with gr.Blocks() as demo:<br>    with gr.Tab(&quot;Greet&quot;):<br>        name_input = gr.Textbox(label=&quot;Enter your name&quot;)<br>        greet_button = gr.Button(&quot;Greet Me&quot;)<br>        greet_output = gr.Textbox(label=&quot;Greeting&quot;)<br><br>        greet_button.click(fn=greet, inputs=name_input, outputs=greet_output)<br><br>    with gr.Tab(&quot;Square Function&quot;):<br>        number_input = gr.Number(label=&quot;Enter a number&quot;)<br>        square_button = gr.Button(&quot;Calculate&quot;)<br>        square_output = gr.Textbox(label=&quot;Result&quot;)<br><br>        square_button.click(fn=square, inputs=number_input, outputs=square_output)<br><br>demo.launch()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LsOPXNYDIuWMspAj_muCng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1odZHPQ8dCF7m2Ao37HijQ.png" /></figure><p>So, you can organize your own layout with Blocksand also create Button. You can even create Tabto separate functions into separate tabs.</p><h3>Bonus</h3><p>In addition to the simple examples already described, Gradio still has features that are no less interesting. Such as creating Interfaces for Chatbotsto Streaming Outputfeatures — just like how AI chatbots respond word by word.</p><p>And that’s just the beginning — there’s a lot more to explore. You can dive in and try all awesome feature in Gradio at <a href="https://www.gradio.app/playground">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a6431a6fbd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Your Multiple Container with Docker Network]]></title>
            <link>https://fhinnn.medium.com/deploy-your-multiple-container-with-docker-network-bfbc399be116?source=rss-529ce5686467------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfbc399be116</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containerization]]></category>
            <dc:creator><![CDATA[Dhafin Almas]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 18:15:35 GMT</pubDate>
            <atom:updated>2024-04-08T18:15:35.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h_bjdPjIqxm_7Qc1" /><figcaption>Photo by <a href="https://unsplash.com/@patwhelen?utm_source=medium&amp;utm_medium=referral">Pat Whelen</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I will divide this story into several parts, namely <strong>Problem</strong>, <strong>Solution</strong>, and <strong>Implementation</strong>. I created this story to document the problem I managed to solve and perhaps help readers who have the same problem in the future.</p><h3>Problem</h3><p>A few months ago as a DevOps engineer intern, I got the task to migrate to a container-based architecture. And one of the issues that came up was that I had more than one application container but <strong>all containers had to be accessible on port 80</strong> (<em>http</em>). Meanwhile, we all know that <strong>exposing ports in docker will crash if the same port is used by multiple containers</strong>.</p><h3>Solution</h3><p>From several solutions that I have tried, such as exposing docker ports to different ports such as 8001, 8002 and others. but unfortunately <strong>users also have to write specific ports if they want to visit them</strong>. For example, if I expose one of the containers to 8001 with the domain name example.com then the user must write example.com:8001, it will be difficult for users and not elegant.</p><p>So, I had the idea to<strong> implement a reverse proxy</strong> on all request paths that would lead to each existing application container and <strong>utilizes the docker network</strong> as a connecting path between containers. In addition to solving the problem of exposing with the same port, on the security side, this implementation also makes a container more secure. Before that, I will explain what a reverse proxy is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*Zv2ELSDI4aSiDEFSTavVbg.png" /><figcaption>Reverse Proxy Topology</figcaption></figure><p><strong>Reverse Proxy</strong> is an<strong> intermediary that serves as a link between the client and the server</strong>. so that the client does not directly access the server but only reaches the reverse proxy and will be forwarded by it to the server.</p><h3>Implementation</h3><p>In this implementation, I will use nginx as a reverse proxy and use 2 simple applications that will be run as docker containers. I place the reverse proxy in this implementation on the host server itself and connect it to each container with the docker network, so that we can deploy without expose the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*kI56qksD89TVRztAGH2N7g.png" /><figcaption>Implementation Topology</figcaption></figure><p>The client will access through a reverse proxy on the host and then will be mapped into the docker with the ip on the docker network. So that all traffic must pass through a reverse proxy and cannot directly access the container (<em>the container is not exposed to the public</em>).</p><p>Here are the implementation steps:</p><ol><li>Create Docker Network</li><li>Run Container with spesific IP from Docker network</li><li>Configuration Nginx as Reverse Proxy</li></ol><h4>Create Docker Network</h4><p>First, it is necessary to create a docker network that will be used by each container to connect to the reverse proxy on the host.</p><pre>docker network create --subnet=192.168.0.0/24 --ip-range=192.168.0.128/25 fhinnn</pre><p>For example, I use the command above to create a docker network with subnet /24 and the ip range that can be used is 192.168.0.128/25 or 192.168.0.128–192.168.0.255 with the network name fhinnn.</p><p>To check if there is already a network created, you can use <strong>docker network ls</strong>.</p><h4>Run Container with spesific IP from Docker network</h4><p>Next, just run the container application that you want to deploy by including the available range ip and network name that was created earlier.</p><pre>docker run -d --network fhinn --ip=192.168.0.135 --name app1 nginx <br>docker run -d --network fhinn --ip=192.168.0.136 --name app2 nginx</pre><p>With the command above, I run containers with the names app1 and app 2 using the nginx default image which contains nginx templates, with network fhinnn and specific ip, namely <strong>192.168.0.135 for app1 and 192.168.0.136 for app2</strong>.</p><h4>Configuration Nginx as Reverse Proxy</h4><p>And finally, configure nginx to be the reverse proxy that connects to each container.</p><pre>server {<br>        listen 80;<br>        server_name app1.yourdomain.com<br>        error_log /var/log/nginx_app1/error.log;<br>        access_log /var/log/nginx_app1/access.log;<br><br>        location / {<br>        proxy_pass http://192.168.0.135;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>    }<br>}<br><br>server {<br>        listen 80;<br>        server_name app2.yourdomain.com<br>        error_log /var/log/nginx_app2/error.log;<br>        access_log /var/log/nginx_app2/access.log;<br><br>        location / {<br>        proxy_pass http://192.168.0.136;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>    }<br>}</pre><p>With the configuration code, nginx will receive a request and if the request is in the form of the app1.yourdomain.com, it will be forwarded to the app1 container and likewise if it is on app2 (<em>Note that nginx can process requests even on the same port as long as they have different nameservers</em>). so you need to set up 2 different domains or you can create 2 subdomains from one domain</p><p>Don’t worry if you don’t have a domain to try this, I have an alternative which is to create 2 different endpoints.</p><pre>server {<br>        listen 80;<br>        server_name _; <br><br>        location /app1 {<br>        proxy_pass http://192.168.0.135;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>        error_log /var/log/nginx_app1/error.log;<br>        access_log /var/log/nginx_app1/access.log;<br>    }<br>        location /app2 {<br>        proxy_pass http://192.168.0.136;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>        error_log /var/log/nginx_app2/error.log;<br>        access_log /var/log/nginx_app2/access.log;<br>    }<br>}</pre><p>with this code, you can still deploy even without a domain, but the way to visit it is different, that is, if you want to visit app1 you have to write the localhost/app1 as well as if app2.</p><p>Foila, finally you can deploy multiple containers without having to worry about conflict port problems.</p><p>Thank you for reading and following my story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfbc399be116" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>