<?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 Emilio Castro on Medium]]></title>
        <description><![CDATA[Stories by Emilio Castro on Medium]]></description>
        <link>https://medium.com/@scrambledbits?source=rss-9ca0d11d570a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YWUro2CPw4fAbWXC.jpg</url>
            <title>Stories by Emilio Castro on Medium</title>
            <link>https://medium.com/@scrambledbits?source=rss-9ca0d11d570a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:37:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@scrambledbits/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[Docker in 2026: Less tutorials, more architecture]]></title>
            <link>https://scrambledbits.medium.com/docker-in-2026-less-tutorials-more-architecture-4e2a2068bb04?source=rss-9ca0d11d570a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e2a2068bb04</guid>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Emilio Castro]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 00:00:36 GMT</pubDate>
            <atom:updated>2026-07-03T07:44:55.117Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P0Q5GqauXypgsZSM" /><figcaption>Photo by <a href="https://unsplash.com/@hdbernd?utm_source=medium&amp;utm_medium=referral">Bernd 📷 Dittrich</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Nearly everyone uses Docker nowdays, but the reality is that most people use it incorrectly. We continue to write Dockerfiles based on decade-old tutorials, resulting in slow pipelines, unnecessary cloud costs, and avoidable security holes.</p><p>This isn’t a command guide. If you’re looking for a docker run tutorial, there are thousands online. Here we will discuss why your current configuration is likely problematic and how to correct it from an architectural perspective.</p><h3>1. Fundamentals: The real value of Docker</h3><p>To understand optimization, first let us remember why Docker won the virtualization war.</p><p>The analogy is simple: a Virtual Machine (VM) is like an independent house; it has its own foundation and plumbing (a complete operating system). A container is like an apartment in a modern building; you share the foundation (the host kernel) but have your own door and key. It is lighter, starts instantly, and consumes fewer resources.</p><p>If you want to delve into low-level mechanics — how Namespaces, Cgroups, and why kernel isolation is the difference between a secure system and a vulnerable one — I recommend reading my analysis on <a href="https://emiliocastro.com.mx/blog/contenedores-y-maquinas-virtuales/">Containers and Virtual Machines</a>. Understanding this foundation is what allows you to stop following trends and start making real technical decisions.</p><p>The base remains the same: the <strong>Image</strong> is the plan, the <strong>Container</strong> is the execution, and the <strong>Registry</strong> is the catalog.</p><h3>2. Anatomy of a Dockerfile: Disaster to Efficiency</h3><p>In the current context, where we deploy from microservices to AI tool servers (such as MCP servers), the difference between a “working” Dockerfile and an “optimized” one is the difference between a deployment taking 10 seconds or 10 minutes.</p><p>Imagine we are packaging a Node.js application.</p><h3>Internet Tutorial Approach (Bad Practices)</h3><p>This is the typical Dockerfile you see in rapid tutorials. It works, but it’s a problem in production.</p><pre># BAD: Heavy image, no pinned version<br>FROM node:latest</pre><pre># BAD: It copies everything BEFORE installing dependencies (breaks cache)<br>COPY . .</pre><pre># BAD: It installs dev dependencies in the final image<br>RUN npm install</pre><pre># BAD: Runs as root by default<br>CMD [&quot;npm&quot;, &quot;start&quot;]</pre><p><strong>Why this is a disaster?</strong></p><ol><li><strong>Nonexistent Cache:</strong> Any change in a comment of your code forces Docker to run npm install from scratch. Your build takes 10 minutes instead of 10 seconds.</li><li><strong>Obese Image:</strong> The final image includes the compiler, build tools, and millions of node_modules files that are not needed to run the app. In an AI environment, where images are already heavy due to models, adding this noise is unacceptable.</li><li><strong>Security Risk:</strong> If someone compromises your app, they have full access to the container as root.</li></ol><h3>Professional Approach (Good Practices)</h3><p>Here we apply architecture. We will use <strong>Multi-stage Builds</strong> and layer optimization.</p><pre># --- Phase 1: Build ---<br>FROM node:20-alpine AS build<br>WORKDIR /app</pre><pre># Layer optimization: We copy only the dependency files first.<br>COPY package.json pnpm-lock.yaml ./<br>RUN npm install</pre><pre># Then we copy the rest of the code<br>COPY . .<br>RUN npm run build</pre><pre># --- Phase 2: Runtime ---<br>FROM node:20-alpine<br>WORKDIR /app</pre><pre># Security: We create an unprivileged user<br>RUN addgroup -S appgroup &amp;&amp; adduser -S appuser -G appgroup</pre><pre># We just copy the compiled artifact created in the previous phase<br># This reduces the image size from several GBs to some MBs<br>COPY --from=build /app/dist ./dist<br>COPY --from=build /app/package.json ./</pre><pre>USER appuser<br>HEALTHCHECK --interval=30s --timeout=3s CMD curl -f <a href="http://localhost:3000/health">http://localhost:3000/health</a> || exit 1</pre><pre>CMD [&quot;node&quot;, &quot;dist/main.js&quot;]</pre><h3>3. Key Optimization Concepts</h3><p>For this flow to work, you need to master three concepts:</p><h3>Layer Caching</h3><p>Docker builds images in layers. Each instruction (COPY, RUN, ADD) creates a new layer.</p><ul><li><strong>Golden Rule:</strong> If a layer changes, all subsequent layers are invalidated and must be rebuilt.</li><li><strong>Strategy:</strong> Put what changes least (like dependency installation) at the beginning and what changes most (like source code) at the end.</li></ul><p>Today, tools like <a href="https://depot.dev/">Depot</a> take this to the next level using native SSD shared cache between runners, eliminating the bottleneck of layer downloads in CI/CD pipelines.</p><h3>Multi-stage Builds (Multi-stage Construction)</h3><p>This is the technique of using multiple FROM images in a single Dockerfile. You can review the <a href="https://docs.docker.com/build/building/multi-stage/">official Docker documentation</a> for more technical details.</p><ul><li><strong>How it works:</strong> Use a heavy image with all compilation tools to generate your binary or bundle. Then, create a second minimal (runtime) image and <strong>only copy the final result</strong>.</li><li><strong>Result:</strong> You eliminate noise. Your final image does not contain source code or compilers. This is critical when deploying lightweight servers like <a href="https://modelcontextprotocol.io/">MCP (Model Context Protocol)</a> agents, where start-up speed is a priority.</li></ul><h3>The Lie of the “Up” State (Health Checks)</h3><p>This is where most engineers fail. They rely on the container being Up, believing that if the process exists, the application is working. <strong>This is a lie.</strong></p><p>A process can be alive (the Node.js process is running) but stuck in an infinite deadlock, have the database crashed, or have thrown an “uncaptured” exception leaving the server process in a “zombie” state. For Docker, the process remains there, so the container remains Up, but your user is seeing a 500 error.</p><p>HEALTHCHECK is the way to tell Docker: <em>&quot;Don&#39;t just check if the process exists; run this command and, if it doesn&#39;t respond with a 200 OK, mark the container as </em><em>unhealthy&quot;</em>. This allows the orchestrator (like Kubernetes or Docker Swarm) to automatically restart the container or stop sending traffic to it. Without real health checks, you are flying blind.</p><p><strong>A final detail:</strong> Forget the tag latest. In production, latest is a time bomb. The professional standard are cryptographic digests (e.g., node@sha256:...). Tags can change; hashes are the only guarantee that what you deployed is exactly what you compiled.</p><h3>Conclusion</h3><p>Docker evolved from being a convenient tool to becoming the unified runtime of the modern stack. Understanding these bases is not an “extra” for the infrastructure engineer; it is the minimum requirement to avoid inefficient pipelines and security risks.</p><p><strong>Pro Tip:</strong> If you want to see a real example of how to optimize a React application from a basic Dockerfile to a production-optimized one, you can review my masterclass repository: <a href="https://github.com/ScrambledBits/masterclass-docker-ejemplo">masterclass-docker-ejemplo</a>. There I left the complete path: from error to efficient solution.</p><p><em>Originally published at </em><a href="https://emiliocastro.com.mx/blog/docker-2026/"><em>https://emiliocastro.com.mx</em></a><em> on June 24, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e2a2068bb04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering CI/CD with GitLab: Bonus Insights and Best Practices]]></title>
            <link>https://scrambledbits.medium.com/mastering-ci-cd-with-gitlab-bonus-insights-and-best-practices-baacc0e21497?source=rss-9ca0d11d570a------2</link>
            <guid isPermaLink="false">https://medium.com/p/baacc0e21497</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[pipeline]]></category>
            <dc:creator><![CDATA[Emilio Castro]]></dc:creator>
            <pubDate>Tue, 12 Mar 2024 17:00:10 GMT</pubDate>
            <atom:updated>2024-03-12T17:00:10.440Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mE7r9E2ZBS31bHfO" /><figcaption>Photo by <a href="https://unsplash.com/@austinchan?utm_source=medium&amp;utm_medium=referral">Austin Chan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As we explore further into the realm of Continuous Integration and Continuous Deployment (CI/CD) with GitLab, this bonus installment aims to provide you with additional insights, best practices, and real-world applications to enhance your CI/CD journey. Whether you’re refining an existing pipeline or building one from scratch, these tips and stories from the trenches will help you navigate common challenges and harness the full potential of GitLab CI/CD. You can also read <a href="https://scrambledbits.com/mastering-ci-cd-with-gitlab-a-beginners-guide-part-1-450b5c4796d9">Part 1</a> and <a href="https://scrambledbits.com/mastering-ci-cd-with-gitlab-advancing-your-pipeline-part-2-c057a0b5c20c">Part 2</a> of these series.</p><h3>Best Practices for CI/CD with GitLab</h3><p>Adopting best practices is key to maximizing the efficiency and effectiveness of your CI/CD pipeline. Here are some strategies embraced by successful teams:</p><h3>Keep Your Pipelines Fast and Focused</h3><ul><li><strong>Parallelize tests</strong> to reduce execution time.</li><li><strong>Use cache and artifacts</strong> wisely to avoid unnecessary steps.</li><li><strong>Trim down your pipeline</strong> by regularly evaluating each job’s necessity and performance.</li></ul><h3>Make Security a Priority</h3><ul><li>Integrate <strong>security scans (SAST, DAST)</strong> into your pipeline to catch vulnerabilities early.</li><li>Use <strong>container scanning</strong> to ensure your Docker images are free from known vulnerabilities.</li><li>Regularly <strong>update dependencies</strong> to mitigate security risks.</li></ul><h3>Automate Everything Possible</h3><ul><li>From code linting to deployment, <strong>automate repetitive tasks</strong> to reduce human error and free up developer time for tasks that require creativity and critical thinking.</li></ul><h3>Monitor and Optimize Continuously</h3><ul><li><strong>Monitor pipeline performance</strong> to identify bottlenecks.</li><li>Continually <strong>refine and optimize</strong> your pipeline based on performance data and team feedback.</li></ul><h3>Overcoming Common CI/CD Challenges</h3><p>Implementing CI/CD can come with its set of challenges. Here are some common ones and strategies to overcome them:</p><h3>Handling Complex Deployments</h3><ul><li>Use <strong>environments</strong> and <strong>deployment strategies</strong> in GitLab to manage complex deployment scenarios, like canary deployments or blue-green deployments.</li></ul><h3>Ensuring High Availability</h3><ul><li>Implement <strong>redundant runners</strong> and utilize <strong>auto-scaling</strong> to maintain high availability and scalability of your CI/CD pipeline.</li></ul><h3>Managing Pipeline Configuration</h3><ul><li>Keep your .gitlab-ci.yml <strong>clean and organized</strong> by using <strong>includes</strong> and <strong>templates</strong> to avoid duplication and improve readability.</li></ul><h3>Real-World Applications</h3><p>Learning from real-world applications can provide valuable insights into effective CI/CD practices:</p><h3>Case Study: Deploying Microservices</h3><ul><li>A tech company streamlined their microservices deployment by adopting <strong>GitLab CI/CD with Kubernetes</strong>, achieving faster rollouts and better scalability.</li></ul><h3>Example: Automated Testing in Gaming Development</h3><ul><li>A game development studio integrated automated testing into their CI/CD pipeline, significantly reducing bugs and improving game quality pre-launch.</li></ul><h3>Insights from Open Source Projects</h3><ul><li>Many open source projects on GitLab provide <strong>public </strong><strong>.gitlab-ci.yml files</strong>. These can be great resources for learning and inspiration.</li></ul><h3>Conclusion</h3><p>This bonus installment of our CI/CD series with GitLab has aimed to provide you with advanced insights, best practices, and real-world applications to take your CI/CD efforts to the next level. Embracing these strategies and learning from others’ experiences can help you overcome challenges and make the most of GitLab’s powerful CI/CD capabilities.</p><p>Your journey with CI/CD is ongoing, and the landscape is always evolving. Stay curious, stay informed, and never hesitate to experiment with new ideas to keep your pipelines efficient, secure, and aligned with your development goals.</p><p>With this we wrap up our series on CI/CD with GitLab, providing a deeper dive into best practices, addressing common challenges, and showcasing real-world applications to inspire and guide your CI/CD strategy. If you have any further questions, need clarification on any of the topics discussed, or are looking for advice on specific CI/CD scenarios, feel free to reach out!</p><p>Thank you for joining me in this exploration of CI/CD with GitLab. May your builds be green and your deployments smooth!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baacc0e21497" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering CI/CD with GitLab: Advancing Your Pipeline — Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://scrambledbits.medium.com/mastering-ci-cd-with-gitlab-advancing-your-pipeline-part-2-c057a0b5c20c?source=rss-9ca0d11d570a------2"><img src="https://cdn-images-1.medium.com/max/2600/0*7l6x-5E6Zo5Ek-aQ" width="4032"></a></p><p class="medium-feed-snippet">In the first part of this series, we covered the basics of setting up a CI/CD pipeline with GitLab. Now, let&apos;s take your pipeline to the&#x2026;</p><p class="medium-feed-link"><a href="https://scrambledbits.medium.com/mastering-ci-cd-with-gitlab-advancing-your-pipeline-part-2-c057a0b5c20c?source=rss-9ca0d11d570a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://scrambledbits.medium.com/mastering-ci-cd-with-gitlab-advancing-your-pipeline-part-2-c057a0b5c20c?source=rss-9ca0d11d570a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c057a0b5c20c</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Emilio Castro]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 15:32:12 GMT</pubDate>
            <atom:updated>2024-03-11T15:32:12.941Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Mastering CI/CD with GitLab: A Beginner’s Guide — Part 1]]></title>
            <link>https://scrambledbits.medium.com/mastering-ci-cd-with-gitlab-a-beginners-guide-part-1-450b5c4796d9?source=rss-9ca0d11d570a------2</link>
            <guid isPermaLink="false">https://medium.com/p/450b5c4796d9</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <dc:creator><![CDATA[Emilio Castro]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 15:32:08 GMT</pubDate>
            <atom:updated>2024-03-05T15:32:08.628Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Mastering CI/CD with GitLab: A Beginner’s Guide — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O4_HDO8C-igALMtB" /><figcaption>Photo by <a href="https://unsplash.com/@realaxer?utm_source=medium&amp;utm_medium=referral">T K</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Continuous Integration (CI) and Continuous Deployment (CD) are fundamental to modern DevOps practices, enabling teams to automate the testing and deployment of code. GitLab, a popular open-source git repository manager, offers an integrated solution for CI/CD, making it an excellent choice for beginners and seasoned developers alike. In this two-part series, we’ll explore how to set up a basic CI/CD pipeline using GitLab and GitLab CI, starting with core concepts and moving on to a simple yet illustrative example.</p><h3>Understanding CI/CD with GitLab</h3><p><strong>Continuous Integration (CI)</strong> involves automatically testing code changes in a shared repository several times a day. <strong>Continuous Deployment (CD)</strong> extends this by automatically deploying the code to production after passing the tests. GitLab CI/CD is a tool built into GitLab that allows users to apply these practices through configuration files within their GitLab repositories.</p><h3>Why GitLab CI/CD?</h3><ul><li><strong>Integrated Solution</strong>: GitLab offers a seamless experience for source code management and CI/CD.</li><li><strong>Flexibility</strong>: Supports complex workflows and diverse project environments.</li><li><strong>Community and Documentation</strong>: A strong community and comprehensive <a href="https://docs.gitlab.com/ee/ci/">documentation</a> make it easy to get started and troubleshoot issues.</li></ul><h3>Setting Up Your First Pipeline</h3><p>A pipeline defines the steps that are run when you commit code to a repository in GitLab. At its simplest, a pipeline could consist of stages like build, test, and deploy.</p><h3>Step 1: Create a GitLab Repository</h3><p>Before setting up CI/CD, you need a GitLab repository. If you don’t have one, you can create it by following the official <a href="https://docs.gitlab.com/ee/gitlab-basics/create-project.html">GitLab repository creation guide</a>.</p><h3>Step 2: Create a .gitlab-ci.yml File</h3><p>This file is where you define your CI/CD pipeline. Place it in the root of your repository. Here’s a simple example to start with:</p><pre>stages:<br>  - build<br>  - test<br>  - deploy<br>build_job:<br>  stage: build<br>  script:<br>    - echo &quot;Building the project...&quot;<br>test_job:<br>  stage: test<br>  script:<br>    - echo &quot;Running tests...&quot;<br>deploy_job:<br>  stage: deploy<br>  script:<br>    - echo &quot;Deploying to production...&quot;</pre><h3>Step 3: Understanding the Pipeline Configuration</h3><ul><li><strong>stages</strong>: Defines the order of stages that the pipeline will execute. Each stage contains a group of jobs that run in parallel.</li><li><strong>build_job, test_job, deploy_job</strong>: These are the names of the jobs associated with each stage. Each job performs specific tasks defined in the script section.</li><li><strong>script</strong>: Contains the commands that are executed as part of each job. These commands can range from simple shell commands to complex scripts, depending on the requirements of your pipeline.</li></ul><h3>Step 4: Running Your Pipeline</h3><p>Once you’ve created your .gitlab-ci.yml file and pushed it to your repository, GitLab automatically detects it and triggers the pipeline based on the configurations defined. You can monitor the progress and outcomes of your pipeline through the GitLab interface by navigating to the CI/CD tab of your repository.</p><h3>Beyond Basics: Expanding Your CI/CD Pipeline</h3><p>After setting up a basic pipeline, you may want to explore more advanced features of GitLab CI/CD, such as:</p><ul><li><strong>Artifacts</strong>: Use artifacts to pass data between stages or save output for later use.</li><li><strong>Caching</strong>: Speed up your pipeline runs by caching dependencies or other frequently used files.</li><li><strong>Environments and Deployments</strong>: Configure deployment jobs to deploy your application to different environments, such as staging or production.</li></ul><h3>Starter Projects to Explore CI/CD Concepts</h3><p>Diving into starter projects can significantly help in understanding and applying CI/CD concepts. Here are five types of projects recommended for beginners:</p><ol><li><strong>Web Application Deployment</strong>: Start with a simple web application to learn the deployment process across different environments.</li><li><strong>Docker Container Workflow</strong>: Understand how to build, test, and push Docker images to a registry as part of your pipeline.</li><li><strong>Automated Testing Implementation</strong>: Implement unit and integration tests to automatically verify the quality of your code with every commit.</li><li><strong>Static Site Deployment</strong>: Use CI/CD to automate the build and deployment process of a static website using generators like Hugo or Jekyll.</li><li><strong>Infrastructure as Code Deployment</strong>: Explore deploying infrastructure using code with tools like Terraform or Ansible, allowing you to version control and review infrastructure changes.</li></ol><p>For detailed examples and further exploration, refer to GitLab’s official <a href="https://docs.gitlab.com/ee/ci/examples/">examples directory</a> and the <a href="https://docs.gitlab.com/ee/ci/">CI/CD documentation</a>.</p><h3>Conclusion</h3><p>Setting up a CI/CD pipeline in GitLab is a gateway to automating your development and deployment processes, making them more efficient and error-proof. By understanding the basic concepts and exploring various starter projects, you’re well on your way to mastering CI/CD with GitLab.</p><p>Stay tuned for the next installment of this series, where we’ll delve into more advanced GitLab CI/CD configurations and best practices to optimize your development workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=450b5c4796d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>