<?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 Mohamed sarda on Medium]]></title>
        <description><![CDATA[Stories by Mohamed sarda on Medium]]></description>
        <link>https://medium.com/@mohamedsarda?source=rss-ae0321610cd9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vnlO187FwtjcS6Az8i67yw.png</url>
            <title>Stories by Mohamed sarda on Medium</title>
            <link>https://medium.com/@mohamedsarda?source=rss-ae0321610cd9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:54:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamedsarda/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[Inception Unraveled: How I Containerized My First Full Stack Setup]]></title>
            <link>https://medium.com/@mohamedsarda/inception-unraveled-how-i-containerized-my-first-full-stack-setup-d52e4a7540e7?source=rss-ae0321610cd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d52e4a7540e7</guid>
            <dc:creator><![CDATA[Mohamed sarda]]></dc:creator>
            <pubDate>Fri, 23 May 2025 18:05:10 GMT</pubDate>
            <atom:updated>2025-05-23T18:05:10.637Z</atom:updated>
            <content:encoded><![CDATA[<h3>NGINX: The Powerful Web Server and Reverse Proxy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MNYkyw02Pe98HfcTbOc3vw.png" /></figure><h3>What Makes NGINX Special?</h3><ul><li>Web Server: Nginx serves static files like HTML, CSS, and JavaScript, and can also handle dynamic content by integrating with application servers.</li><li>Reverse Proxy: Nginx acts as a reverse proxy, distributing incoming requests to multiple backend servers, balancing the load, and providing high availability.</li><li>Load Balancing: Nginx evenly distributes incoming traffic across multiple servers to improve performance and handle more concurrent connections.</li><li>Caching: Nginx can cache static and dynamic content in memory, reducing the load on backend servers and improving response times.</li><li>SSL/TLS Termination: Nginx handles SSL/TLS encryption and decryption, offloading the processing from backend servers and improving performance.</li><li>Security: Nginx provides access control, request filtering, rate limiting, and can be configured as a firewall to protect against web attacks.</li><li>High Availability: Nginx supports high-availability configurations for continuous service even if servers fail, with options for automatic failover.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*4YfCAPWeCBdGpVJacv3XFA.png" /></figure><h3>Understanding TLS: Securing Your Web Traffic</h3><p>A TLS connection is initiated using a sequence known as the TLS handshake. When a user navigates to a website that uses TLS, the TLS handshake begins between the user’s device (also known as the client device) and the web server.</p><p>During the TLS handshake, the user’s device and the web server:</p><ul><li>Specify which version of TLS (TLS 1.0, 1.2, 1.3, etc.) they will use</li><li>Decide on which cipher suites they will use</li><li>Authenticate the identity of the server using the server’s TLS certificate</li><li>Generate session keys for encrypting messages between them after the handshake is complete</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUeegT08BFMn1MzMoTEIuw.png" /></figure><p>The TLS handshake establishes a cipher suite for each communication session. The cipher suite is a set of algorithms that specifies details such as which shared encryption keys, or session keys, will be used for that particular session. TLS is able to set the matching session keys over an unencrypted channel thanks to a technology known as public key cryptography.</p><p>The handshake also handles authentication, which usually consists of the server proving its identity to the client. This is done using public keys. Public keys are encryption keys that use one-way encryption, meaning that anyone with the public key can unscramble the data encrypted with the server’s private key to ensure its authenticity, but only the original sender can encrypt data with the private key. The server’s public key is part of its TLS certificate.</p><p>Once data is encrypted and authenticated, it is then signed with a message authentication code (MAC). The recipient can then verify the MAC to ensure the integrity of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2axB1pqslYJtcBZ5Vhop_A.png" /></figure><h3>OpenSSL Implementation Guide: Creating Self-Signed Certificates</h3><pre>RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \<br>    -keyout /etc/nginx/tls/nginx.key \<br>    -out /etc/nginx/tls/nginx.crt \<br>    -subj &quot;/C=MA/ST=KHOURIBGA/L=KHOURIBGA/O=1337/OU=1337/CN=msarda.42.fr/UID=msarda&quot;<br><br>CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]</pre><ul><li>req: Creates and processes certificate requests</li><li>-x509: Generates a self-signed certificate instead of a certificate request</li><li>-nodes: Creates a certificate without password protection (no encryption)</li><li>-days 365: Sets the certificate validity period to one year</li><li>-newkey rsa:2048: Creates a new 2048-bit RSA private key</li><li>-keyout: Specifies where to save the private key</li><li>-out: Indicates where to save the certificate</li><li>-subj: Provides certificate subject information:</li><li>/C: Country code (MA for Morocco)</li><li>/ST: State or Province Name</li><li>/L: Locality Name (city)</li><li>/O: Organization Name</li><li>/OU: Organizational Unit</li><li>/CN: Common Name (your domain)</li><li>/UID: User ID</li></ul><h4>nginx -g -daemon off</h4><ul><li><strong>nginx</strong> → starts the Nginx server.</li><li><strong>-g</strong> → allows you to pass global config directives via CLI.</li><li><strong>&quot;daemon off;&quot;</strong> → tells Nginx <strong>not</strong> to run in the background (daemon mode), but to stay in the foreground.</li></ul><h3>NGINX Configuration Architecture: Building a Robust Web Foundation</h3><pre>events{} # Needed by Nginx, even if it&#39;s empty. Just part of the syntax.<br>http<br>{<br>    client_max_body_size 300M; # Allows uploads up to 300MB. Without this, large file uploads (like images, videos) will fail.<br>    include /etc/nginx/mime.types; #Tells Nginx how to handle different file types like .css, .js, .png, etc.<br>    server {<br>        listen              443 ssl; #Serve HTTPS on port 443 (standard for secure web traffic).<br>        server_name msarda.42.fr; #Nginx will respond only if the domain is msarda.42.fr.<br><br>        ssl_protocols TLSv1.3; # Use TLS 1.3 only - fast and secure.<br><br>        #Public cert and private key - needed for HTTPS to work.<br>        ssl_certificate /etc/nginx/tls/nginx.crt;<br>        ssl_certificate_key /etc/nginx/tls/nginx.key;<br><br>        root /var/www/html; #The folder Nginx serves files from.<br>        index index.php; #Default file it looks for if you just hit the domain (like msarda.42.fr).<br><br>        #This checks if the file exists; if not, it throws a 404. Without it, static files like .html, .css, .js may not work right.<br>        location / {<br>          try_files $uri $uri/ =404;<br>        }<br>        #Any request ending in .php gets passed to a PHP processor.<br>        location ~ \.php$ {<br>            #Basic PHP processing rules - sets up stuff like headers, request methods, etc.<br>            include snippets/fastcgi-php.conf;<br>            #Forwards the PHP request to a service/container named wordpress running on port 9000.<br>            fastcgi_pass wordpress:9000;<br>        }<br>    }<br>}</pre><h3>MariaDB: High-Performance Relational Database Engine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*esjpg0i2IYP7o-mropHJmw.png" /></figure><p>MariaDB Server is an open-source relational database management system (RDBMS) that is a drop-in replacement for MySQL. It was developed by the original creators of MySQL after concerns about the direction of MySQL under Oracle Corporation. MariaDB aims to be a community-developed, feature-compatible, and open-source alternative to MySQL.</p><p>MariaDB Server is designed to be highly compatible with MySQL, which means that most applications and tools developed for MySQL can work seamlessly with MariaDB without requiring any modifications. It supports standard SQL and offers a wide range of features, including ACID compliance, transactions, stored procedures, triggers, views, and more.</p><h3>MariaDB Container Initialization and Configuration</h3><pre># Starts the MariaDB service, You need the DB server running before running any SQL commands.<br>service mariadb start<br>sleep 5<br><br># Creates a database if it doesn’t already exist.<br>mysql -u root -e &quot;CREATE DATABASE IF NOT EXISTS ${SQL_DATABASE};&quot;<br><br># Creates a new user with the username ${DB_USER} and password ${DB_PASS}, @&#39;%&#39; means the user can connect from any host.<br>mysql -u root -e &quot;CREATE USER IF NOT EXISTS \`${DB_USER}\`@&#39;%&#39; IDENTIFIED BY &#39;${DB_PASS}&#39;;&quot;<br><br># Grants full access to ${DB_USER} on the ${SQL_DATABASE}. Also sets their password to ${DB_PASS}<br>mysql -u root -e &quot;GRANT ALL PRIVILEGES ON ${SQL_DATABASE}.* TO &#39;${DB_USER}&#39;@&#39;%&#39; IDENTIFIED BY &#39;${DB_PASS}&#39;;&quot;<br><br># Reloads privilege tables so changes take effect immediately, Uses the root password to execute it securely.<br>mysql -u root -p&quot;${SQL_ROOT_PASSWORD}&quot; -e &quot;FLUSH PRIVILEGES;&quot;<br><br><br>service mariadb stop<br><br># Starts MariaDB in safe mode, listening on all network interfaces (0.0.0.0) on port 3306.<br># This is the real run command — safe mode is more robust and logs errors better.<br>mysqld_safe --port=3306 --bind-address=0.0.0.0</pre><h3>WordPress: Content Management at Enterprise Scale</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rsMp_mjvNMtga2AxFxo5w.png" /></figure><h3>The WordPress Ecosystem: Beyond Simple Blogging</h3><p>WordPress is a popular open-source content management system (CMS) and website creation tool. It is written in PHP and uses a MySQL or MariaDB database to store content. WordPress allows users to create and manage websites, ranging from simple blogs to complex e-commerce sites and corporate websites.</p><h3>WP-CLI: Command Line Mastery for WordPress Administrators</h3><p>The WordPress Command Line Interface (WP-CLI) is a powerful command-line tool that allows users to interact with WordPress installations through the command line. It provides a set of commands for managing various aspects of a WordPress site, such as configuring settings, managing plugins and themes, performing updates, and interacting with the database.</p><h3>Key Capabilities of WP-CLI</h3><p>With WP-CLI, you can perform tasks efficiently and automate common WordPress management tasks. Some common tasks that can be performed using WP-CLI include:</p><ul><li>Installing WordPress: You can use WP-CLI to download and install WordPress on your server, including setting up the database and configuring the site.</li><li>Managing Plugins and Themes: WP-CLI allows you to install, activate, deactivate, and update plugins and themes from the WordPress.org repository or local files. You can also list installed plugins and themes, search for new ones, and delete them.</li><li>Updating WordPress: WP-CLI enables you to update WordPress core, plugins, and themes with a single command. This can be particularly useful when managing multiple sites or automating updates.</li><li>Configuring WordPress: You can modify various WordPress settings using WP-CLI, such as site title, URL, admin credentials, and permalinks. It allows you to set options directly in the database without accessing the WordPress admin dashboard.</li><li>Managing Users: WP-CLI provides commands to manage users, including creating new users, updating user information, and assigning user roles.</li><li>Performing Database Operations: You can interact with the WordPress database using WP-CLI. It allows you to run SQL queries, export/import the database, and perform other database-related operations.</li><li>Running Maintenance Tasks: WP-CLI includes commands for performing maintenance tasks like clearing caches, optimizing the database, and repairing the site.</li></ul><h3>Automating WordPress Installation with WP-CLI</h3><p>To illustrate the power of WP-CLI, let’s examine a script that fully automates the installation and configuration of a WordPress site with Redis caching:</p><pre>#!/bin/bash<br><br># Waits 5 seconds to ensure MariaDB is fully up before continuing<br>sleep 5<br><br># Downloads WordPress core files (latest version) into the current directory<br>wp core download --allow-root<br><br># Creates the wp-config.php file using environment variables<br>wp config create --dbname=$SQL_DATABASE \<br>                --dbuser=$DB_USER \<br>                --dbpass=$DB_PASS \<br>                --dbhost=mariadb:3306 --allow-root 1&gt;/dev/null<br><br># Installs WordPress with site URL, title, and admin credentials<br>wp core install --url=$SITE_URL \<br>                --title=$SITE_TITLE \<br>                --admin_user=$ADMIN_USER \<br>                --admin_password=$ADMIN_PASS \<br>                --admin_email=$ADMIN_EMAIL --allow-root 1&gt;/dev/null<br><br># Creates an additional user with the specified role and credentials<br>wp user create $USERNAME \<br>               $EMAIL \<br>               --role=$ROLE \<br>               --user_pass=$PASSWORD --allow-root 1&gt;/dev/null<br><br># Installs and activates the Zino theme<br>wp theme install zino --activate --allow-root<br><br># Installs and activates the Redis cache plugin<br>wp plugin install redis-cache --activate --allow-root<br><br># Sets Redis host and port in wp-config.php<br>wp config set WP_REDIS_HOST $REDIS_HOST --allow-root<br>wp config set WP_REDIS_PORT $REDIS_PORT --allow-root<br><br># Flushes Redis cache to clean any existing data<br>wp redis flush --allow-root<br><br># Enables Redis object caching in WordPress<br>wp redis enable --allow-root<br><br>echo &quot;Redis enabled ✅&quot;<br><br># Makes sure PHP-FPM run directory exists<br>mkdir -p /run/php/<br><br># Changes PHP-FPM config to listen on port 9000 instead of a Unix socket<br>sed -i &#39;s|listen = /run/php/php7.4-fpm.sock|listen = 9000|&#39; /etc/php/7.4/fpm/pool.d/www.conf<br><br># Fixes file permissions for WordPress directory<br>chown -R www-data:root /var/www/html<br>chmod -R 777 /var/www/html<br><br>echo &quot;you can visit msarda.42.fr ✅&quot;<br><br># Starts PHP-FPM in the foreground so the container stays alive<br># exec : replaces the current shell process with the command. That means:<br># Proper signal handling (e.g., Ctrl+C, Docker stop signals).<br># No zombie processes.<br># Cleaner resource usage in containers.<br><br>exec php-fpm7.4 -F</pre><h3>Redis: In-Memory Performance Acceleration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmjiSSWD3esWQdUP8e7Qaw.png" /></figure><p>Redis is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. It provides high performance, scalability, and a rich set of data structures.</p><h3>Redis Containerization Strategy &amp;&amp; Initialization Script</h3><pre>#dockerfile<br>FROM debian:bullseye<br><br>RUN apt update &amp;&amp; apt install -y redis-server &amp;&amp; apt clean &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/*<br><br>COPY conf/redis.sh /usr/local/bin/redis.sh<br>RUN chmod +x /usr/local/bin/redis.sh<br><br>EXPOSE 6379<br><br>CMD [&quot;/usr/local/bin/redis.sh&quot;]</pre><pre>#!/bin/bash<br># conf/redis.sh<br>echo &quot;Starting redis-server...&quot;<br>exec redis-server --protected-mode no</pre><p>The command redis-server — protected-mode no is used to start the Redis server with the protected mode feature disabled.</p><h3>What is Protected Mode?</h3><p>When protected mode is enabled (the default behavior), Redis only allows connections from clients on the same host or from clients that authenticate using a password. This is a security measure to prevent unauthorized access to the Redis server.</p><h3>Why Disable Protected Mode?</h3><p>By specifying — protected-mode no, the Redis server starts without protected mode, allowing connections from any client without authentication. Disabling protected mode can be useful during development or in certain network configurations where authentication is not required or managed separately.</p><h3>Adminer: Lightweight Database Management Interface</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*zAxeBivoOmHXXgADXDXA0g.png" /></figure><h4>What Is Adminer?</h4><p>Adminer (formerly phpMinAdmin) is a PHP-based, free, open source database management tool. It’s super simple to deploy on your server. To use it, all you have to do is upload its single PHP file, point your browser towards it, and log in.</p><p>Adminer’s basic login page Unlike phpMyAdmin, which only supports the management of MySQL and MariaDB databases, Adminer also supports managing other databases such as PostgreSQL, SQLite, MS SQL, Oracle, SimpleDB, Elasticsearch, MongoDB, and Firebird. It is also available in 43 languages.</p><p>Adminer provides an easy-to-use interface, better support for many MySQL features, more remarkable performance, and increased security.</p><h3>Adminer Container Implementation</h3><pre>RUN mkdir -p /var/www/adminer<br><br>RUN wget https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php -O /var/www/adminer/index.php<br><br>CMD [&quot;php&quot;, &quot;-S&quot;, &quot;0.0.0.0:8000&quot;, &quot;-t&quot;, &quot;/var/www/adminer&quot;]</pre><p>The command php -S 0.0.0.0:8000 -t /var/www starts the PHP built-in web server with the following parameters:</p><ul><li>-S 0.0.0.0:8000 : Instructs the PHP interpreter to start the built-in web server. 0.0.0.0 represents all available network interfaces, and 8000 is the port number to listen on. This configuration allows the web server to listen on all available IPv4 interfaces.</li><li>-t /var/www : Specifies the document root directory for the web server. In this case, it is set to /var/www, meaning that the web server will serve files from that directory.</li></ul><h3>Portainer: Visual Docker Management Platform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gfU3AMdRlZhpWyRUAyD0g.png" /></figure><p>Portainer is an open-source management tool for Docker that provides a graphical user interface (GUI) to manage and monitor Docker environments. It allows users to easily deploy, manage, and scale containers, as well as monitor resources and view container logs.</p><h4>Key features of Portainer include:</h4><ul><li>Docker Management: Portainer provides a web-based interface to manage Docker containers, images, networks, volumes, and other Docker resources. It allows you to easily create, start, stop, and remove containers, as well as manage container networks and persistent storage.</li><li>Container Templates and Stacks: Portainer offers a catalog of pre-defined templates and application stacks that can be used to quickly deploy popular applications and services as containers. These templates simplify the process of setting up containerized applications without the need for manual configuration.</li><li>User and Access Management: Portainer supports role-based access control, allowing you to define user roles and assign permissions for different users or user groups. This ensures that only authorized individuals can access and manage specific Docker resources.</li><li>Resource Monitoring: Portainer provides real-time monitoring of CPU, memory, and network usage for containers and Docker hosts. It allows you to track resource utilization and identify potential performance bottlenecks.</li><li>Container Logs and Exec Console: Portainer allows you to view and search container logs directly from the web interface. You can also access an interactive console to execute commands inside running containers for troubleshooting and debugging purposes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QuTw6J9MUgqO3U_USxoQeg.png" /></figure><h3>FTP: Secure File Transfer Implementation</h3><h4>FTP in Modern Architecture</h4><p>FTP, which is short for File Transfer Protocol, is a network protocol that was once widely used for moving files between a client and server. FTP is still used to support legacy applications and workflows with very specific needs. If you have a choice on protocol, consider modern options that are more efficient, secure, and convenient for delivering files. For example, Internet users who download directly from their web browser with https, and command line users who use secure protocols such as the scp or SFTP.</p><h4>vsftpd: Secure and Stable FTP Server</h4><p>vsftpd, very secure FTP daemon, is an FTP server for many Unix-like systems, including Linux, and is often the default FTP server for many Linux distributions as well. vsftpd is beneficial for optimizing security, performance, and stability. It also provides strong protection against security problems found in other FTP servers. vsftpd can handle virtual IPD configurations, encryption support with SSL integration, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iYwewUGYi2fIoyYDdqlwaQ.png" /></figure><h4>FTP Modes Explained</h4><h4>Active Mode:</h4><p>In active mode, the FTP server initiates the data connection to the client.</p><p>When the FTP client requests a file transfer in active mode, it sends a PORT command to the server, specifying an IP address and port number on which it is listening for data connections.</p><p>In response, the FTP server initiates a connection from its own IP address to the IP address and port specified by the client.</p><p>Active mode requires the FTP client to be accessible directly from the Internet and have its own public IP address.</p><p>It can be challenging to use active mode through firewalls or network address translation (NAT) devices because the server initiates the connection to the client, which may be blocked or modified by network configurations.</p><h4>Passive Mode:</h4><p>In passive mode, the FTP client initiates the data connection to the server.</p><p>When the FTP client requests a file transfer in passive mode, it sends a PASV command to the server.</p><p>The server responds with an IP address and port number on which it is listening for data connections.</p><p>The FTP client then initiates a connection from its own IP address to the IP address and port specified by the server.</p><p>Passive mode is commonly used in situations where the client is behind a firewall or NAT device, as the client is responsible for establishing the data connection.</p><p>Passive mode requires the FTP server to be configured to listen on a specific port range for incoming data connections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/0*KF8ZTagCn-9UhWnJ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d52e4a7540e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker Made Simple: A Beginner’s Guide]]></title>
            <link>https://medium.com/@mohamedsarda/docker-made-simple-a-beginners-guide-b2505096d41d?source=rss-ae0321610cd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2505096d41d</guid>
            <dc:creator><![CDATA[Mohamed sarda]]></dc:creator>
            <pubDate>Fri, 25 Apr 2025 13:57:54 GMT</pubDate>
            <atom:updated>2025-05-23T18:07:11.925Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@mohamedsarda/inception-unraveled-how-i-containerized-my-first-full-stack-setup-d52e4a7540e7">Inception documentation</a></p><p>Docker is a powerful tool that might seem complex at first, but it’s actually designed to make your life easier! Let me break it down in simple terms for someone who’s completely new to the concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2FdumcO6OFQBi4_Y.png" /></figure><h3>What is Docker?</h3><p>Imagine you’re a chef who wants to share your special recipe with friends. Instead of just giving them a list of ingredients and hoping their kitchens have everything needed, you could give them a complete “cooking kit” with all ingredients pre-measured and all necessary tools included. That’s what Docker does for computer programs!</p><p>Docker lets you package an application along with everything it needs to run (like libraries, configuration files, and dependencies) into a standardized unit called a <strong>container</strong>. This container can then run on any computer that has Docker installed, regardless of differences in the underlying system.</p><h3>Why is Docker Useful?</h3><ul><li><strong>Consistency</strong>: Your application runs exactly the same way everywhere</li><li><strong>Isolation</strong>: Applications don’t interfere with each other</li><li><strong>Efficiency</strong>: Uses fewer resources than traditional virtual machines</li><li><strong>Portability</strong>: Works the same on your laptop, a cloud server, or anywhere else</li></ul><h3>How Docker Works: The Basics</h3><h3>The Building Blocks</h3><ol><li><strong>Docker Image</strong>: Think of this as a recipe or blueprint. It contains all the instructions and ingredients needed to create a container.</li><li><strong>Docker Container</strong>: This is a running instance of an image — like the actual meal created from a recipe. It’s a lightweight, standalone package that includes everything needed to run the application.</li><li><strong>Docker Registry</strong>: A place where images are stored and can be downloaded (like Docker Hub — think of it as a cookbook library).</li><li><strong>Docker Client</strong>: The tool you use to interact with Docker (giving commands like “create container” or “stop container”).</li><li><strong>Docker Daemon</strong>: The background service that manages everything (builds, runs, and distributes containers).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mCzGexnQq7WO4GG-.jpeg" /></figure><h3>Behind the Scenes: How Docker Creates Isolation</h3><p>Docker uses two key technologies to create safe, isolated environments:</p><h4>1. Namespaces — Creating Separate Spaces</h4><p>Namespaces are like invisible boundaries around containers. They ensure that what happens in one container stays in that container:</p><ul><li><strong>Process Namespace</strong>: Each container gets its own list of running programs</li><li><strong>Network Namespace</strong>: Each container has its own network settings (like having separate IP addresses)</li><li><strong>File System Namespace</strong>: Each container sees only its own files</li><li><strong>Hostname Namespace</strong>: Containers can have their own unique names</li><li><strong>User Namespace</strong>: Users in containers are separate from users on the host system</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Clw_-bxveuGup35l.png" /></figure><h4>2. Control Groups (Cgroups) — Managing Resources</h4><p>Cgroups act like resource managers, controlling how much of the computer’s power each container can use:</p><ul><li>Limit memory usage (e.g., “this container can only use 500MB of RAM”)</li><li>Control CPU usage (e.g., “this container gets 50% of CPU time”)</li><li>Manage disk space and network bandwidth</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6TMCBW9-EW4JKiKZ.png" /></figure><h3>Docker in Practice: A Simple Example</h3><p>Imagine you want to run a small website. Without Docker, you’d need to:</p><ol><li>Install a web server</li><li>Configure it</li><li>Install dependencies</li><li>Set up your website files</li><li>Start the server</li></ol><p>With Docker, you can do this in one command:</p><pre>docker run --name my-website --memory=&quot;500m&quot; nginx</pre><p>This command:</p><ul><li>Pulls the nginx (web server) image from Docker Hub</li><li>Creates a container named “my-website”</li><li>Limits it to 500MB of memory</li><li>Starts the web server</li></ul><h3>Key Benefits for Beginners</h3><ul><li><strong>No “Works on My Machine” Problems</strong>: Share your application with others and it will run exactly the same way on their computers</li><li><strong>Easy Experimentation</strong>: Try new software without messing up your computer</li><li><strong>Clean Uninstalls</strong>: When you’re done, just delete the container — no leftover files</li><li><strong>Version Control</strong>: Keep different versions of your application separate</li></ul><p>Docker simplifies the process of developing, shipping, and running applications, making it easier for developers and users alike to work with software consistently across different environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/0*q8a6GEk1lZKnuwsh.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2505096d41d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FT_IRC :  Channels and Command Management]]></title>
            <link>https://medium.com/@mohamedsarda/ft-irc-channels-and-command-management-ff1ff3758a0b?source=rss-ae0321610cd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff1ff3758a0b</guid>
            <dc:creator><![CDATA[Mohamed sarda]]></dc:creator>
            <pubDate>Sun, 29 Dec 2024 14:16:07 GMT</pubDate>
            <atom:updated>2024-12-29T14:17:38.186Z</atom:updated>
            <content:encoded><![CDATA[<h3>FT_IRC<strong> : </strong>Channels and Command Management</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*2NTrDO-Mjm7Q7wRI" /></figure><p>IRC (Internet Relay Chat) is one of the earliest forms of online communication, enabling real-time text-based interactions between users in chat rooms or private messages. In this blog, we’ll guide you through creating your custom IRC server in C++ and connecting to it with an IRC client like irssi.</p><p>This project was developed as part of a team effort:</p><p><a href="https://medium.com/@mohcin.ghalmi/irc-server-internet-relay-chat-bd08e4f469f8"><strong>Mohcine Ghalmi</strong>:</a> Focused on server implementation and client communication.<br><a href="https://medium.com/@mohamedsarda2001/ft-irc-channels-and-command-management-ff1ff3758a0b"><strong>Mohamed Sarda:</strong></a> Specialized in implementing and managing IRC channels.</p><p>github project page <a href="https://github.com/Mohcine-Ghalmi/ft_irc">IRC</a></p><h3><strong>Architectural:</strong></h3><p>A typical <strong>IRC</strong> network consists of servers and clients connected to server, with a good mix of <strong>IRC </strong>operators and channels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*PcrQ_6wRnWl9yoD_" /></figure><h3><strong>Servers :</strong></h3><p>Servers form the backbone of <strong>IRC</strong>, providing a point to which clients may connect and talk to each other, and a point for other servers to connect to, forming an <strong>IRC</strong> network.</p><p>The most common network configuration for <strong>IRC</strong> servers is that of a spanning tree where the server acts as a central node for the rest of the network (clients).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/0*YVnTKzG3eOyHkmnm" /></figure><h3><strong>Clients:</strong></h3><p>A client is anything connecting to a server that is not another server. Each client is distinguished from other clients by a unique <strong>nickname</strong>. In addition to the nickname, all servers must have the following information about all clients: the real <strong>name(</strong>user name<strong>)/address</strong> of the host that the client is connecting from, the username of the client on that host, and the server to which the client is connected</p><p>The client registers with the <strong>IRC </strong>server using a username and must set a nickname with the <strong>NICK</strong> command in order to communicate (or update the old nickname).</p><h3><strong>Operators:</strong></h3><p>To allow a reasonable amount of order to be kept within the <strong>IRC</strong> network, a special class of clients (operators) are allowed to perform general maintenance functions on the network such as remove users.</p><h3><strong>Channels:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*Z_Ei5Wrx9J0r5bbc" /></figure><p>A channel is a named group of one or more clients. All clients in the channel will receive all messages addressed to that channel. The channel is created implicitly when the first client joins it, and the channel ceases to exist when the last client leaves it. While the channel exists, any client can reference the channel using the name of the channel.</p><p>There are several types of channels used in the IRC protocol. But we are using the standard type of channel that is the <strong>regular channel</strong> which is known to all servers that are connected to the network. The prefix character for this type of channel is <strong>(‘#’, 0x23)</strong>.</p><p>To create a new channel or become part of an existing channel, a user is required to join the channel using the <strong>JOIN</strong> command. If the channel doesn’t exist prior to joining, the channel is created and the creating user becomes a channel operator. If the channel already exists, whether or not the client successfully joins that channel depends on the modes currently set on the channel. For example, if the channel is set to invite-only mode (+i), the client only joins the channel if they have been invited by another user or they have been exempted from requiring an invite by the channel operators.</p><p>Channels also contain a <strong>TOPIC</strong>. The topic is a line shown to all users when they join the channel, and all users in the channel are notified when the topic of a channel is changed. Channel topics commonly state channel rules, links, quotes from channel members, a general description of the channel, or whatever the <strong>channel operatoer </strong>want to share with the clients in their channel.</p><p>A user may be joined to several channels at once, but a limit may be imposed by the server as to how many channels a client can be in at one time.</p><h3><strong>Channels Operators:</strong></h3><p>Channel operators (or “<strong>chanops</strong>”) on a given channel are considered to ‘<strong>run</strong>’ or ‘<strong>own</strong>’ that channel. In recognition of this status, channel operators are endowed with certain powers which let them moderate and keep control of their channel.</p><p>Channel moderators are identified by the channel member prefix ‘<strong>@</strong>’ for standard channel operators,</p><p>The commands which may only be used by channel moderators include:</p><ul><li><strong>JOIN </strong>:</li></ul><p>Allows a user to join a specific channel.</p><pre>/join #channel</pre><ul><li><strong>PRIVMSG</strong> :</li></ul><p>Sends the message Hello, everyone! to the #channel.</p><pre>/privmsg #channel Hello, everyone!</pre><ul><li><strong>PART</strong> :</li></ul><p>User leaves the channel #channel.</p><pre>/part #channel</pre><ul><li><strong>KICK </strong>: Eject a client from the channel (message optional)</li></ul><pre>/kick #channel User1 --&gt; Removes User1 from the #channel.</pre><ul><li><strong>MODE </strong>: Change the channel’s modes</li></ul><p>Example of : MODE command that combines all the modes (i, t, o, l, and k) :</p><pre>/mode #channel +it-lk+o-o user1 5 password user2</pre><ul><li><strong>i : </strong>Only users with invites may enter the channel.</li></ul><pre>/mode #channel +i --&gt; Enable invite-only mode</pre><ul><li><strong>+t : </strong>Only channel operators can change the channel topic.</li></ul><pre>/mode #channel -t --&gt; Disable topic restriction</pre><ul><li><strong>+k : </strong>Sets a channel key such that only users knowing the key can enter</li></ul><pre>/mode #channel +k secure123 --&gt; Set a channel key to secure123</pre><ul><li><strong>+o : </strong>Channel operator</li></ul><pre>/mode #channel +o user1 --&gt; Grant operator to user1</pre><ul><li><strong>+l : </strong>Limits number of users able to be on channel (when full, no new users can join)</li></ul><pre>/mode #channel +l 15 --&gt; Limit the channel to 15 users</pre><ul><li><strong>INVITE </strong>: Invite a client to an invite-only channel (mode +i)</li></ul><pre>/invite User1 #channel</pre><ul><li><strong>TOPIC </strong>: Change the channel topic</li></ul><pre>/topic #channel New Topic! --&gt; Sets the topic of #channel to New Topic!.</pre><h3><strong>Communication Types:</strong></h3><p><strong>One-to-one communication: </strong>Servers should be able to send a message from any one client to any other.</p><p><strong>One-to-many communication(Channel):</strong> In IRC, the channel has a role equivalent to that of the multicast group; their existence is dynamic and the actual conversation carried out on a channel is generally sent only to servers which are supporting users on a given channel, and only once to every local link as each server is responsible for fanning the original message to ensure it will reach all recipients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTbteQEqA8w_YUuGjaoM3g.png" /></figure><p>consider the IRC servers are the channels.</p><h3>Weather Bot :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*zrnHBl5YsnmPJUzh" /></figure><p>The Weather Bot is an automated client integrated into the IRC server to provide real-time weather updates. It fetches data from external APIs and delivers weather information directly to users or channels.</p><p><strong>Dynamic Weather Queries</strong>:</p><ul><li>Users can request weather information for any location.</li><li>Command syntax: /weather &lt;location&gt;.</li></ul><p><strong>Channel Announcements</strong>:</p><ul><li>Automatically posts weather updates to specified channels at regular intervals.</li><li>Customizable settings for update frequency and target channels.</li></ul><p><strong>Error Handling</strong>:</p><ul><li>Graceful handling of API errors or invalid locations with user-friendly error messages.</li></ul><p><strong>Weather Query Processing</strong>: Handles requests and interacts with the weather API.</p><pre>std::string WeatherBot::getWeatherData(const std::string &amp;location);</pre><ul><li><strong>Automated Announcements</strong>: Posts weather updates to channels periodically.</li></ul><pre>void WeatherBot::postWeatherUpdate(Channel &amp;channel);</pre><h3>Integration with the IRC Server</h3><ul><li>The Weather Bot operates as a virtual user.</li><li>It listens for /weather commands and responds with the requested information.</li><li>Scheduled updates are sent via:</li></ul><pre>Server::broadcastToChannel(Channel &amp;channel, const std::string &amp;message);</pre><h3>Example Usage</h3><ul><li>Requesting weather for New York:</li></ul><p>/weather New York</p><ul><li>Response:</li></ul><p>WeatherBot: Current weather in New York: 15°C, Clear skies.</p><ul><li>Automatic announcement in</li></ul><p>#general: <strong>WeatherBot: [Update] Paris: 12°C, Light Rain.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff1ff3758a0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>