<?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 Kate Mwaura on Medium]]></title>
        <description><![CDATA[Stories by Kate Mwaura on Medium]]></description>
        <link>https://medium.com/@katemwaura44?source=rss-e1fb3ba6dbe6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KRovKdiA1UwH7ckVNwY7eA.png</url>
            <title>Stories by Kate Mwaura on Medium</title>
            <link>https://medium.com/@katemwaura44?source=rss-e1fb3ba6dbe6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:03:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@katemwaura44/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[The Engineering Behind Shipping Java: Maven Builds, Docker Containers, and Deployment Pipelines]]></title>
            <link>https://medium.com/@katemwaura44/the-engineering-behind-shipping-java-maven-builds-docker-containers-and-deployment-pipelines-11309c72d3c6?source=rss-e1fb3ba6dbe6------2</link>
            <guid isPermaLink="false">https://medium.com/p/11309c72d3c6</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Kate Mwaura]]></dc:creator>
            <pubDate>Fri, 22 May 2026 12:03:41 GMT</pubDate>
            <atom:updated>2026-05-22T12:03:41.755Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Built a Maven Multi-Module Spring Boot Service and Containerized It End to End</h3><p><em>A greeting endpoint that returns “Hello, name!” is not impressive. The Maven multi-module build, multi-stage Docker pipeline, and full observability stack surrounding it that’s a different conversation.</em></p><p>Most backend tutorials have the same ending. The endpoint works. The JSON comes back clean. Everyone nods, closes the terminal, and moves on quietly agreeing that the system is “done.” But done is a generous word for what that usually is. What’s actually done is the application. The system the build pipeline, the runtime environment, the deployment flow, the observability layer, the security posture that part hasn’t started yet.</p><p>That gap between “the application works” and “the system is production-ready” is where the most interesting engineering actually lives. And it’s also where most projects quietly give up.</p><p>This project started with a deliberately boring premise: a single /greet endpoint that returns a name. No complex business logic. No domain modeling. No database. Just Hello, name! coming back over HTTP. The simplicity was intentional because the moment an application gets complicated, the infrastructure underneath it disappears behind the business logic. I wanted the engineering layer fully exposed, visible enough to examine how software actually moves from a source file on a developer&#39;s machine into a running, observable, production-style system.</p><p>What that examination revealed changed how I think about devops entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5TYs-GIaJZibCeNbLcGYvg.png" /></figure><p><em>The full picture source code on the left, observable running platform on the right. Every arrow between them is a decision that either holds under pressure or doesn’t.</em></p><h3>The Build Layer: Where Discipline Lives Before the Code Runs</h3><p>The first decision that changed the character of the project was splitting it into a Maven multi-module structure. For a service this small, that was objectively unnecessary. A single module would have worked. But production systems are rarely designed around what is sufficient today they are designed around what remains manageable later, when new modules get added, when teams grow, when version drift starts accumulating silently across a codebase.</p><p>The parent POM became the single source of truth for the entire build. Dependency versions, plugin configuration, shared build behavior all of it centralized in one place, inherited without duplication by every child module that comes after. The child module, greeting-api, carried only what was specific to itself: its own source code, its own plugin executions, its own packaging logic.</p><p>That architecture immediately made the project feel different. Less like a tutorial. More like something that had been designed to scale.</p><p>And then it immediately broke in an interesting way.</p><p>The Docker build kept failing with Non-resolvable parent POM for com.example:greeting-api. At first it looked like a dependency resolution issue — the kind of error that sends you down a rabbit hole of repository configuration and plugin versions. The actual problem was architectural. The Docker build context was wrong. The build was being run from inside the greeting-api directory, which meant Docker could see the child module but had no visibility into the parent POM sitting one level above it. Maven couldn&#39;t resolve the inheritance chain because the chain was invisible from where the build was standing.</p><p>The fix was one line moving the build command to the project root. But the lesson underneath it was more durable: multi-module systems have spatial requirements that single-module projects don’t. The moment you introduce structural relationships between components, every tool in your pipeline needs to understand that structure, not just the component it’s immediately pointing at. That failure showed up again later in subtler ways throughout the project and recognizing its shape early made it much faster to diagnose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*956envGbfF91taP0Fxt90A.png" /></figure><p><em>The parent POM controls everything above the line. The child inherits everything and adds only what is specific to itself. Version consistency enforced in one place one of those decisions that feels like overhead until the second module arrives.</em></p><p>This was also the moment where JaCoCo entered the picture as something more than a reporting tool. An 80% instruction coverage gate was wired into the verify phase, which meant the build would fail not warn, not log, fail if test coverage dropped below that threshold. The JAR would never be produced.</p><p>That distinction matters more than it first appears. A coverage report that you can ignore is just noise. A coverage gate that blocks the build is a structural guarantee. It changes the incentive from “I should probably write some tests” to “the artifact does not exist without tests.” The 80% threshold was chosen deliberately high enough to make untested behavior visible, low enough to avoid the trap where engineers start writing meaningless assertions just to satisfy a number. Coverage as an engineering signal, not as the definition of quality.</p><h3>From Source to Artifact: What the Build Actually Produces</h3><p>mvn clean package is three words, but what it actually does is worth understanding in sequence. Maven works through the full lifecycle cleaning out stale artifacts, compiling source into bytecode, running the test suite, enforcing the coverage gate, and finally repackaging the result into an executable fat JAR through the Spring Boot Maven plugin. The fat JAR is self-contained: application classes, all dependencies, and an embedded Tomcat server, wrapped into a single file that can run anywhere Java 21 is installed.</p><p>In a multi-module project, Maven processes this as a Reactor build the parent first, the child after, in dependency order. That sequencing matters because the parent has to exist before the child can inherit from it. The terminal output makes this visible through the Reactor Build Order, which is Maven’s way of declaring its execution plan before it starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4coM49Ee9YMQ5Dcee5JGpg.png" /></figure><p><em>Both modules, processed in sequence. JaCoCo instruments, the Spring Boot plugin repackages, and BUILD SUCCESS arrives in 38.5 seconds. The fat JAR sitting in </em><em>target/ is the only output that matters everything else was scaffolding.</em></p><p>That fat JAR becomes the handoff point between the build system and the container layer. Everything before it is Maven’s responsibility. Everything after it is Docker’s.</p><h3>Profiles: One Artifact, Multiple Environments</h3><p>Before containers entered the picture, there was a simpler problem worth solving first: how to make the same application behave differently across environments without changing any code between deployments.</p><p>Spring profiles solve this cleanly. The project uses three layered configuration files application.properties as the shared base, application-dev.properties for local development, and application-prod.properties for the container runtime. The active profile gets injected at startup through a JVM argument, an environment variable, or a Docker Compose configuration block. The application itself never needs to know how it was activated. It just behaves according to whichever environment it finds itself in.</p><p>In development, the application runs on port 9090 with DEBUG-level logging streaming directly to the console. In production, it runs on port 9080 with structured file-based logging and restricted log levels. Same JAR. Same code. Completely different operational behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6qapCx2oilMNW421e6pdA.png" /></figure><p><em>One artifact, three environments, zero code changes between them. The active profile is the only variable everything else flows from it.</em></p><p>The thing that makes this pattern valuable in production isn’t the ports or the log levels. It’s the principle underneath: environment-specific behavior should live in configuration, not in code. The moment you hardcode environment values into the application, you’ve coupled the deployment to the environment. Every new environment requires a code change. Every code change requires a build. Spring profiles break that coupling entirely.</p><h3>Containers and the Illusion of Local Development</h3><p>Running the application on the host machine feels clean and predictable. You see logs immediately. You hit the endpoint. Everything behaves exactly as expected. Containers remove that illusion and they do it in ways that are educational precisely because they’re unexpected.</p><p>The Docker build for this project uses a multi-stage approach, and the reasoning behind that structure is worth understanding rather than just accepting. A single-stage build would produce a runtime image containing Maven, the JDK, all build tooling, the source code, and the dependency cache everything that was needed to build the application, now permanently embedded in the thing that gets deployed. That image is larger, harder to audit, and exposes build-time tooling to a runtime environment where it has no business being.</p><p>Multi-stage builds solve this by separating concerns at the filesystem level. Stage one uses a full Maven and JDK image with one responsibility: compile the source, resolve dependencies, produce the JAR. Stage two starts completely fresh from a minimal JRE Alpine image and copies only the final artifact across. Maven is gone. The JDK is gone. Source code is gone. The dependency cache is gone. The runtime image contains exactly two things: the Java runtime and the application JAR.</p><p>The result is a 229MB image instead of the 376MB Maven build image. But the more important result is a smaller attack surface. What isn’t in the image can’t be exploited.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LADuUq1UVRWVlUw9TyOPQg.png" /></figure><p><em>Stage 1 builds everything. Stage 2 keeps almost nothing. The gap between them is where production discipline lives.</em></p><p>There was a real build failure here worth mentioning not because it was dramatic, but because it reveals something about how multi-module projects behave inside containers. The spring-boot-maven-plugin was declared in the parent&#39;s pluginManagement block without the repackage goal explicitly wired in the child POM. Maven built a thin JAR instead of an executable fat JAR. The container started, and the application refused to run: no main manifest attribute. The fix was adding a single &lt;execution&gt; block to the child POM. But the diagnosis required understanding the difference between declaring a plugin in pluginManagement and actually activating a goal a distinction that only becomes visible when something downstream depends on the output being in a specific format.</p><h3>When a Request Enters the Container</h3><p>Once the image was running, something interesting happened when I actually traced what occurs between a curl command hitting the host machine and a response coming back. That path is longer than it looks.</p><p>The request hits Docker’s port mapping at 9080:9080 the bridge between the host network and the container network. Inside the container, embedded Tomcat is listening on port 9080. The request passes through Spring MVC&#39;s DispatcherServlet into the GreetingController, where the name parameter is extracted, sanitized with HtmlUtils.htmlEscape(), logged through SLF4J, and returned as a plain text response. Actuator endpoints run alongside the application at /actuator/health and /actuator/info, exposing runtime health without touching any application internals.</p><p>That path from host port mapping through Docker networking into an embedded application server through a controller and back is the architecture of almost every containerized Java application, just expressed at a scale where every component is visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mMpHZS-ynJYQALfVPHhvg.png" /></figure><p><em>Every request makes this journey. At this scale it’s visible. At production scale it’s the same journey, with more complexity at each node.</em></p><h3>Logging: The Part That Changes Completely in Production</h3><p>Of all the architectural shifts in this project, the one that felt most like a genuine revelation was logging specifically, the realization that production logging is almost the inverse of development logging.</p><p>In development, logs exist for humans. They should be verbose, readable, and immediate. You want to see every debug message, every request parameter, every lifecycle event, streaming directly to your terminal in real time. Fast feedback is the only metric that matters.</p><p>In production, logs exist for systems. They need to be structured enough for aggregation platforms to parse, restricted enough to avoid filling disks, durable enough to survive container restarts, and formatted for long-term querying rather than immediate readability. The human isn’t watching the terminal. A log shipper is.</p><p>This project handles that split through logback-spring.xml with &lt;springProfile&gt; blocks a single configuration file that activates different behavior depending on which Spring profile is running. In dev, logs stream to a ConsoleAppender at DEBUG level. In prod, logs go to a RollingFileAppender at /app/logs/greeting-api.log with size-based and time-based rotation, a 30-day retention policy, and a 1GB total cap to prevent disk saturation.</p><p>The choice to use logback-spring.xml over basic application.properties logging was deliberate. Property-based logging configuration handles simple cases cleanly, but it can&#39;t express rolling policies, retention rules, profile-aware appender selection, or per-destination log levels. The moment production logging requirements go beyond &quot;write to a file,&quot; you need Logback&#39;s XML configuration system. The tradeoff is verbosity logback-spring.xml is a harder file to read than a handful of properties. But it&#39;s a logging setup that actually reflects how production systems are configured, not a simplified version of one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gqRXm65sFSMwUTbehMGlHw.png" /></figure><p><em>SLF4J is the abstraction the code never knows what’s underneath it. Logback is the engine. The profile is the switch. In prod, nothing reaches the console.</em></p><p>The moment this clicked in practice was when the production container was running and the console showed nothing. Not errors. Not startup messages. Nothing. The application was handling requests confirmed by curling the endpoint but the terminal was silent. The logs were inside the container, written to /app/logs/greeting-api.log, completely invisible from the outside unless you explicitly exec&#39;d into the container or mounted the volume.</p><p>That silence is intentional. Production environments are not built around terminal visibility. They’re built around aggregation pipelines Fluentd, Promtail, or Filebeat collecting from mounted log directories and shipping into Grafana Loki or the ELK stack. The architecture in this project makes that pipeline possible. The /app/logs/ directory is designed to be a Docker volume mount, which means a log shipper can reach it from outside the container without any changes to the application.</p><h3>Orchestration: When the Stack Becomes a System</h3><p>Running the API in isolation is useful for development. The real environment this project was designed for is different the API, SonarQube, and Snyk running together as a connected, networked platform with shared volumes, injected environment variables, and service-level isolation between components.</p><p>docker compose up --build brings all of that up with a single command. Docker Compose builds the greeting-api image, pulls SonarQube and Snyk if they&#39;re not already present, creates an isolated bridge network called greetings-net, starts all three containers connected to that network, and begins streaming logs from all services simultaneously. The entire local platform API, code quality analysis, dependency scanning comes alive together.</p><p>The networking behavior is one of the more instructive parts of this setup. Inside greetings-net, containers don&#39;t communicate through IP addresses or localhost. They communicate through service names. greeting-api reaches SonarQube at http://sonarqube:9000. That&#39;s it. No IP resolution, no manual network configuration. Docker creates internal DNS entries for each service name automatically, and containers use those names to find each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwBLaMV2J5hAJOyE9N9FVg.png" /></figure><p><em>Three containers, one network, zero manual IP management. The service name is the address. This is the same mental model Kubernetes uses just expressed through Compose at local scale.</em></p><p>That mental model service discovery by name rather than by address is one of those concepts that feels like a small implementation detail until you realize it’s the foundational networking model of every modern container orchestration system. Kubernetes doesn’t use IP addresses either. Services reach each other through DNS names. The concepts are identical. The tooling just scales differently.</p><p>Environment variables handle runtime configuration injection cleanly here. SPRING_PROFILES_ACTIVE=prod activates the production profile inside the container. SNYK_TOKEN gives the scanner access to Snyk&#39;s vulnerability database. Neither of these values touches the image. They&#39;re injected at startup through the Compose configuration, which means the same image runs correctly in any environment where those variables are present.</p><h3>Quality as Architecture: When the Tools Push Back</h3><p>The quality and security pipeline in this project was designed to do something specific: make engineering debt immediately visible rather than allowing it to accumulate quietly between reviews.</p><p>JaCoCo instruments the bytecode during the test phase and produces a coverage report. SonarQube consumes that report alongside the compiled source and runs a full static analysis checking for bugs, code smells, duplicated logic, maintainability issues, and security hotspots, then publishing everything to a dashboard with a quality gate verdict. Snyk runs independently against the Maven dependency tree and the Docker image, scanning for known CVEs in both direct dependencies and transitive ones that SonarQube’s static analysis would never surface.</p><p>These three tools address completely different failure modes. JaCoCo finds untested behavior. SonarQube finds structural and maintainability problems in code that’s already written. Snyk finds vulnerabilities in code you didn’t write but are shipping anyway. Together they cover the quality and security surface of the system in a way that any single tool alone cannot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jpDrjpyMrf5k4Nc6u5qHIg.png" /></figure><p><em>Three tools, three different failure modes, one pipeline. JaCoCo finds untested code. SonarQube finds structural problems. Snyk finds vulnerable dependencies. None of them overlap. All of them are necessary.</em></p><p>What changed structurally once these tools were in place was the character of every decision that came after. When coverage gates exist, tests stop being optional. When static analysis is running, maintainability becomes visible rather than subjective. When dependency scanning is active, adding a library becomes a decision with visible consequences rather than a casual addition to a POM file. The tools don’t force good engineering but they make the cost of cutting corners immediately apparent rather than deferring it to production.</p><p>The SonarQube dashboard after the first clean analysis was genuinely satisfying: zero bugs, zero vulnerabilities, zero security hotspots, 91.7% coverage, 0.0% duplication, all reliability and maintainability ratings at A. Not because the application was complex it wasn’t. But because the engineering discipline around it was real.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NH8jnduNsvnauGwwbB6ng.png" /></figure><p><em>Quality gate: passed. Every metric visible, every threshold enforced. This is what it looks like when the pipeline is doing its job.</em></p><h3>The Failures That Taught More Than the Successes</h3><p>The path to a working deployment was not clean. The troubleshooting section of any real engineering project is usually where the most durable learning happens — not because failures are inherently educational, but because they force you to understand the system at a deeper level than success ever requires.</p><p>Several failures during this project were particularly revealing.</p><p>The Logback initialization problem was one of them. The application was crashing inside the container with No appenders present in context [default]. The &lt;springProfile&gt; blocks in logback-spring.xml were defined correctly, but they weren&#39;t activating. The problem was timing: Logback was initializing before Spring had activated the active profile, which meant the profile-aware configuration blocks evaluated to nothing, and the appenders were defined but never attached to any logger. The fix required adding a fallback &lt;springProfile&gt; block for when no profile is active, and ensuring the logs directory existed inside the container before the application started. Two changes. But understanding why it was happening required tracing the initialization sequence across Logback, Spring Boot, and the container startup order simultaneously three systems interacting in a way that none of their individual documentation makes immediately obvious.</p><p>The port conflict problem was subtler. The application was binding to port 8080 and failing on startup because something else was already listening there. The base application.properties didn&#39;t declare an active profile, so Spring fell back to its default profile and used the default port. The fix was setting spring.profiles.active=dev explicitly in the base configuration file. But diagnosing it required understanding Spring&#39;s profile fallback behavior well enough to realize that the application was running in a profile state that shouldn&#39;t have existed at all.</p><p>The fat JAR failure no main manifest attribute was similarly quiet in its cause. The spring-boot-maven-plugin was declared in the parent&#39;s pluginManagement without the repackage execution explicitly wired in the child POM. Maven built a perfectly valid JAR. It just wasn&#39;t a fat JAR. The distinction between a plugin declared in pluginManagement and a plugin goal actually executing during the build lifecycle is one of those Maven details that only surfaces when you&#39;re depending on a specific output format downstream.</p><p>What connected all of these failures was the same underlying pattern: the system was behaving correctly according to the rules you had actually specified, not the rules you thought you had specified. That gap between intent and specification is where most debugging time actually goes.</p><h3>The Deployment Flow, End to End</h3><p>Looking at the full deployment evolution, the progression tells a clear story.</p><p>mvn clean package compiles, tests, enforces coverage, and produces the fat JAR. Docker picks up that JAR through the multi-stage build and produces a lightweight, secure runtime image. docker compose up --build takes that image and brings up the full platform creating the network, mounting volumes, injecting environment variables, starting all three containers as a connected operational environment. SonarQube runs the static analysis. Snyk scans the dependencies and the image. The quality gate passes or fails.</p><p>Every stage in that chain has a clear input and a clear output. Every tool exists because there’s a specific failure mode it prevents that the tools before it cannot catch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hsAH3Ku4wbNnu1yJb7Z8tg.png" /></figure><p><em>Source to running observable platform. Every arrow is a tool. Every tool has a reason. None of them are decorative.</em></p><h3>The Architecture Decided and Why</h3><p>A few decisions across this project are worth examining explicitly, because they each involved a real tradeoff rather than a default choice.</p><p>The multi-module Maven architecture added complexity to the build. The parent-child POM split introduced the Docker build context failure, added a layer of configuration that a single-module project wouldn’t need, and made the project harder to explain to someone unfamiliar with Maven. It was worth it because the alternative a single module where dependency versions, plugin configuration, and build behavior are all managed in the same place as the application code doesn’t scale. The moment a second module arrives, the single-module approach creates duplication that compounds with every new addition.</p><p>The choice to use logback-spring.xml instead of property-based logging added verbosity to the configuration. The tradeoff is legitimate: the XML file is harder to read. But application.properties cannot express rolling policies, retention limits, per-profile appender selection, or archive configuration. Property-based logging is a simplified interface to a small subset of Logback&#39;s capabilities. When production logging requirements go beyond that subset, the properties abstraction becomes a limitation rather than a convenience.</p><p>The multi-stage Docker build added complexity to the Dockerfile. Debugging build failures is harder when the build happens across two stages in sequence. But the alternative is a production runtime image that contains Maven, the JDK, source code, and build tooling all of which represent both unnecessary size and unnecessary attack surface. The tradeoff is clear.</p><p>Spring profiles over hardcoded configuration is perhaps the most straightforward of the four. Hardcoded environment values create deployments that are tightly coupled to a specific environment. Spring profiles break that coupling entirely, at the cost of additional configuration files to manage.</p><h3>Where the System Goes From Here</h3><p>The current architecture handles local deployment well. The patterns it uses translate directly into the infrastructure decisions that production systems at scale require.</p><p>The natural next step is a database layer PostgreSQL, Spring Data JPA, entity models, schema migration. The Compose stack would extend to orchestrate the database container alongside the API, with a persistent volume keeping data alive across restarts. That addition would also make the application stateful for the first time, which changes the deployment story considerably.</p><p>Docker Compose would eventually give way to Kubernetes. The concepts it introduces service discovery by name, environment injection through configuration, volume management, network isolation translate directly into Kubernetes primitives. Pods, Services, ConfigMaps, and Secrets are the same ideas at a different scale. The mental model transfers.</p><p>The file-based logging setup is already designed to support centralized aggregation. A log shipper like Promtail or Fluentd collecting from /app/logs/ and forwarding into Grafana Loki or the ELK stack would require no changes to the application. The architecture anticipated that pipeline.</p><p>GitHub Actions would automate the entire build-test-analyze-scan-package-deploy sequence on every push removing human error from the release process and enforcing every quality gate automatically before anything reaches a running environment. The pipeline structure already exists. Automating it is a configuration problem, not an architectural one.</p><h3>How the System, Looked at Whole</h3><p>By the end of this project, the greeting endpoint had almost disappeared from view. What was left was everything surrounding it.</p><p>Source code became a packaged artifact. The artifact became a container image. The image became an orchestrated runtime. The runtime became observable. The observable system became measurable through quality and security tooling that enforced standards before deployment rather than discovering failures after.</p><p>That progression from source file to running platform is the actual subject of modern backend engineering. Not the endpoint. Not the business logic. The pipeline that gets code from a developer’s machine into a production-ready, observable, consistently deployable system.</p><p>The interesting part of backend engineering is everything required to make the application production-ready. The application itself is usually the first piece. Building the infrastructure around it the build system that enforces quality, the container layer that isolates the runtime, the orchestration that connects the services, the logging that makes behavior visible, the security tooling that catches vulnerabilities before they ship that’s where the real engineering decisions live.</p><p>The API was never the interesting part.</p><p>Everything required to make the API production-ready was.</p><p><em>The full source code for this project is available at </em><a href="https://github.com/Kate-mwaura/build-systems-lab"><em>github.com/Kate-mwaura/build-systems-lab</em></a><em>. Architecture diagrams, deployment guide, and configuration references are in the </em><em>docs/ folder.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11309c72d3c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Broke a Production Git Repo on Purpose Here’s What I Learned Fixing It]]></title>
            <link>https://medium.com/@katemwaura44/i-broke-a-production-git-repo-on-purpose-heres-what-i-learned-fixing-it-9203c69bd094?source=rss-e1fb3ba6dbe6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9203c69bd094</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Kate Mwaura]]></dc:creator>
            <pubDate>Thu, 02 Apr 2026 18:44:49 GMT</pubDate>
            <atom:updated>2026-04-02T18:44:49.532Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From basic commits to production-grade version control: a hands-on journey into real Git mastery.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9rtJRwKsVEwXL6oeT2KYTQ.png" /></figure><p>There’s a version of Git that tutorials teach you.</p><p><strong>git add . </strong><strong>git commit -m &quot;update&quot; </strong><strong>git push</strong></p><p>And then there’s the version of Git that actually runs production systems the one where a leaked API key at 2am costs a company thousands, where a bad force push from a teammate wipes three days of work, where a merge conflict in a shared codebase can bring a deployment to its knees.</p><p>For a long time, I was living in the tutorial version. I knew the commands. I had a playbook. I could branch, commit, push, and merge without thinking twice. But knowing commands and mastering Git are two completely different things.</p><p>So I did something uncomfortable I deliberately broke a production Git environment. I simulated real chaos: leaked secrets, corrupted history, bad force pushes, unresolvable merge conflicts, diverged branches. Ten challenges. No hand-holding. No step-by-step guide. Just objectives, a terminal, and the pressure of fixing everything without losing a single commit.</p><h3>Why I Did This</h3><p>I was deep into documenting my Git playbook. Every command studied, tested, and explained in my own words when I realized something: I could explain what git rebase -i does. I could define git bisect. I had them in my notes. But could I actually use them when everything was on fire?</p><p>That’s a different question entirely.</p><p>Real DevOps engineers don’t just know version control they use it as a safety net for production systems. Git isn’t just where code lives. It’s how you debug without bringing the company down. It’s how you collaborate with a team of ten without overwriting each other’s work. It’s how you recover from disasters that would otherwise end careers. I wanted to operate at that level. So I built the chaos myself.</p><h3>The Lab Setup</h3><p>The scenario: a real team environment with three branches — main (production), develop (integration), and feature/payment (a buggy feature branch). Ten things had gone wrong simultaneously:</p><ul><li>Messy commit history with duplicated changes and meaningless messages</li><li>A broken merge with real conflict markers</li><li>A leaked API key committed five commits deep in history</li><li>A teammate’s bad force push that wiped the branch</li><li>Diverged local and remote branches</li><li>Submodule dependency tracking broken</li><li>A production bug hiding somewhere in history</li><li>Work-in-progress changes interrupted by an urgent hotfix</li><li>History rewritten incorrectly after a bad revert</li><li>A final boss scenario combining everything at once</li></ul><p>No steps. Just objectives. Fix everything. Lose nothing.</p><h3>The Challenges That Changed How I Think</h3><h3>1. Cleaning Dirty History with Interactive Rebase</h3><p>The develop branch looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tjWeXYc2T0tMdlvQalAroQ.png" /><figcaption><strong>Initial dirty history</strong></figcaption></figure><p>Ten commits. All named “temp.” All sitting between me and a clean, production-readable history.</p><p>Before this lab, I knew <strong>git rebase -i HEAD~n</strong> existed. After it, I understood what it actually does, it lets you rewrite history before it becomes permanent. You can squash ten &quot;temp&quot; commits into one meaningful commit. You can reword messages. You can reorganize the story of your code so that when a teammate runs <strong>git log</strong>, they see intent not chaos.</p><p>The command that saved me: <strong>git rebase -i HEAD~10</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sThTLo6B_6BVkmZzOcZ68g.png" /><figcaption><strong>New commit after</strong> git rebase -i HEAD~10 <strong>squashed the commits to one clean commit.</strong></figcaption></figure><p>The mindset shift: commit history isn’t just a record of what you did. It’s documentation. It’s communication. A clean history is professional courtesy to every engineer who touches that codebase after you.</p><h3>2. Removing a Leaked Secret from ALL of History</h3><p>This one genuinely stressed me out which is exactly the point. An API key had been committed five commits ago. Commit <strong>9a6a69b9672</strong>. It was sitting in the history of a public-facing repo, visible to anyone who cloned it.</p><p>The naive fix — deleting the file and committing again does nothing. The key still lives in every previous commit. Anyone with <strong>git log -p</strong> can find it in seconds. The real fix requires rewriting history entirely:</p><pre>git filter-repo --path secrets.env --invert-paths<br>git push --force-with-lease<br>git gc --prune=now --aggressive</pre><p><strong>git filter-repo</strong> rewrites every commit in the repo&#39;s history, removing the file completely. <strong>git gc --prune=now --aggressive</strong> ensures the old objects are garbage collected and unrecoverable. <strong>--force-with-lease</strong> pushes the rewritten history safely without the risk of overwriting someone else&#39;s work.</p><p><em>What I know now that I didn’t before</em>: the moment a secret is committed, you treat it as compromised. Rotate it immediately, regardless of whether you clean the history. History rewriting is damage control not a guarantee.</p><p><em>I’m not sharing terminal output for this one deliberately if you’re dealing with a real leaked secret, the last thing you need is a screenshot tutorial. Rotate the key first. Then fix the history.</em></p><h3>3. Recovering Lost Work After a Bad Force Push</h3><p>A teammate ran <strong>git push --force</strong>. History was gone. Or so it seemed.</p><p>This is where <strong>git reflog</strong> becomes the most important command you&#39;ve never used seriously. The reflog is Git&#39;s internal diary it records every single thing HEAD has pointed to, even commits that no longer exist in any branch. Deleted commits. Reset history. Force-pushed branches. All of it, preserved for 30 to 90 days.</p><pre>git reflog<br>git checkout f6bbc583c2f<br>git checkout -b recovery_branch</pre><p>Three commands. Work recovered. Branch restored.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9wVBU3IJmdWNvApsvLUJDg.png" /><figcaption><strong>Reset the HEAD~1 commits, and found the commits still exist in the object store by using</strong> &lt;git reflog&gt;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_5qvC-I5TVtumW92E2c-w.png" /><figcaption><strong>Created a new branch from the HAED~1 commit and all the lost commits where restored from the object store.</strong></figcaption></figure><p><em>The lesson:</em> <strong>git push --force</strong> doesn&#39;t delete commits it just removes the branch pointer. The commits still exist in the object store until garbage collection runs. <strong>git reflog</strong> finds them. This is why <strong>--force-with-lease</strong> exists: it force pushes only if no one else has pushed since you last fetched, protecting the team from exactly this scenario.</p><h3>4. Debugging a Production Bug with Git Bisect</h3><p>A bug was introduced somewhere in a 30+ commit history. No one knew which commit. The naive approach reading through every commit one by one would take hours.</p><p>git bisect uses binary search to find the exact commit that introduced a bug in logarithmic time. You tell it one good commit and one bad commit, and it checks out the midpoint. You test, mark it good or bad, and it narrows down. In five steps, across thirty commits, I had the exact commit hash, the exact author, the exact line changed.</p><pre>git bisect start<br>git bisect bad          # current commit is broken<br>git bisect good 00f80b1 # this commit was fine<br># Git checks out midpoint — you test and mark good/bad<br># Repeat until:<br># 239a9d52 is the first bad commit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YN___bMM8dQVHNwLDjvOhQ.png" /><figcaption><strong>Commit</strong> &lt;00f80b1&gt; <strong>was clean from the bug I marked it as good. Next midpoint commit</strong> &lt;c420ee4&gt; <strong>had the bug and I marked it as bad.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gF2njWe9dp_D2R_B8TMoaQ.png" /><figcaption><strong>The search finally landed at commit</strong> &lt;239a9d5&gt; <strong>which had the bug and bisect identified this as the initial commit with the bug and the commit details.</strong></figcaption></figure><p>Before this: I knew git bisect existed. After this: I will never manually hunt a bug through commit history again.</p><h3>5. Rebase vs Revert The One That Almost Killed Me</h3><p>I’ll be honest. This broke my brain.</p><p><strong>git reset</strong> and <strong>git revert</strong> both undo changes. But they are not the same thing and using the wrong one in production is the difference between a clean fix and a catastrophe.</p><p><strong>git reset --hard HEAD~1</strong> moves the branch pointer backwards and discards the commit entirely. On a branch only you&#39;re working on, this is fine. On a shared branch <strong><em>main</em></strong>, <strong><em>develop</em></strong> this rewrites history that other people have already pulled. You&#39;ll create a divergence that&#39;s painful to reconcile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*SAkhCP-6yu-rqrf8HfkL9Q.png" /><figcaption><strong>Commit reset.txt file then run</strong> &lt;git reset --soft HEAD~1&gt; <strong>the commit was removed from the history log and the file was moved to the staging area.</strong></figcaption></figure><p><strong>git revert HEAD</strong> creates a <em>new</em> commit that undoes the changes of the previous one. History stays intact. The revert is documented. The team can see exactly what happened and why. This is the production-safe way to undo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sY_GIx5kAn0Z_1VR_pT7aA.png" /><figcaption><strong>Commit reset.txt file then run</strong> &lt;git revert HEAD&gt; <strong>this undid the HEAD commit and unstaged the commit changes</strong>.</figcaption></figure><pre># The wrong way on a shared branch:<br>git reset --hard HEAD~1</pre><pre># The right way — preserves history, safe for teams:<br>git revert HEAD</pre><p>The rule I now live by: reset for local work, revert for shared history.</p><h3>What Git Actually Is</h3><p>I used to think Git was a way of storing files.</p><p>After this lab, I know better.</p><p>Git is a safety net for production systems. It’s how you debug live code without bringing the company down. It’s how a team of ten engineers works on the same codebase simultaneously without overwriting each other’s work. It’s how you recover from disasters that would otherwise be unrecoverable.</p><p>Branching isn’t just a workflow it’s isolation. You can break everything on a feature branch without touching production. git stash isn&#39;t just a convenience it&#39;s how you handle interruptions professionally, preserving work-in-progress while you jump to an urgent hotfix. git reflog isn&#39;t just a history log it&#39;s the safety net under the safety net, the thing that lets you undo your own mistakes.</p><p>The engineers who operate at production level aren’t just using Git more they are using it differently. Every command is intentional. Every commit message is written for the next person who reads it. History isn’t just a record it’s communication.</p><h3>The Commands That Separate Basic Users from Production Engineers</h3><p>If you’re not regularly using these, you’re not yet operating at production level:</p><pre>git rebase -i HEAD~n        # rewrite history before it hardens<br>git reflog                  # recover anything, from anywhere<br>git bisect start/good/bad   # find bugs in logarithmic time<br>git push --force-with-lease # force push safely<br>git revert HEAD             # undo without rewriting shared history<br>git stash push -u -m &quot;wip&quot;  # save context-switches cleanly<br>git filter-repo             # remove secrets from all of history<br>git cherry-pick &lt;hash&gt;      # apply specific commits across branches</pre><h3>Where I Am Now</h3><p>I started this journey as a basic Git user. <strong>add, </strong><strong>commit, </strong><strong>push</strong>. The essentials.</p><p>After this lab, after deliberately breaking a production environment and fixing it piece by piece I operate differently. Not just because I know more commands, but because I understand what version control actually does in a real engineering team.</p><p>Git is not a backup tool. It’s not a file storage system. It’s a collaboration protocol, a debugging tool, a disaster recovery system, and a communication layer all at once.</p><p>Mastering it doesn’t mean memorizing flags. It means understanding what’s actually happening under the hood, so that when production breaks at 2am, you know exactly which three commands will save the day.</p><h3>My Git Playbook</h3><p>Every command in this article and many more are documented in my personal Git playbook, built through hands-on practice across real scenarios.</p><p>👉 <a href="https://github.com/Kate-mwaura/my-git-playbook">my-git-playbook on GitHub</a></p><p>If you’re on the same journey, I hope this saves you some of the chaos I deliberately put myself through.</p><p><em>Catherine Mwaura is a DevOps Engineer currently building production-grade systems from the ground up and documenting the journey publicly.</em></p><p><em>Follow along on </em><a href="https://github.com/Kate-mwaura"><em>GitHub</em></a><em> · </em><a href="https://www.linkedin.com/in/kate-mwaura"><em>LinkedIn</em></a><em> · </em><a href="https://medium.com/@katemwaura44"><em>Medium</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9203c69bd094" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>