<?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 Nobusherpaa on Medium]]></title>
        <description><![CDATA[Stories by Nobusherpaa on Medium]]></description>
        <link>https://medium.com/@nobusherpaa?source=rss-5489aa0ba64a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GX5zU6v1tDxyllN3</url>
            <title>Stories by Nobusherpaa on Medium</title>
            <link>https://medium.com/@nobusherpaa?source=rss-5489aa0ba64a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:05:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nobusherpaa/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[ Simplifying Multi-Environment React Deployments: One Jenkins Pipeline to Rule Them All]]></title>
            <link>https://medium.com/@nobusherpaa/simplifying-multi-environment-react-deployments-one-jenkins-pipeline-to-rule-them-all-f84383b411a0?source=rss-5489aa0ba64a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f84383b411a0</guid>
            <dc:creator><![CDATA[Nobusherpaa]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 11:51:20 GMT</pubDate>
            <atom:updated>2025-12-19T11:51:20.696Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I streamlined our deployment process from multiple files and complex configurations to a single-click solution</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CnbSZzM0j9Ywk1Y5" /><figcaption>Photo by <a href="https://unsplash.com/@sid_balachandran?utm_source=medium&amp;utm_medium=referral">Sid Balachandran</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The Problem: DevOps Complexity Overload 😵</h3><p>As a frontend developer working on a React application, I found myself drowning in deployment complexity.</p><p>Our setup included:</p><ul><li>Multiple Dockerfiles<br> (Dockerfile.development, Dockerfile.staging, Dockerfile.production)</li><li>Separate docker-compose files for each environment</li><li>Different Nginx configurations per deployment</li><li>Jenkins pipelines with too many parameters</li><li>Manual port and branch management</li></ul><p>Every deployment felt risky.</p><p>I had to remember:</p><ul><li>Which Dockerfile to use</li><li>Which compose file to run</li><li>Which branch matched which environment</li><li>Which port was free</li></ul><p>It was slow, error-prone, and exhausting.</p><blockquote><strong><em>There had to be a better way.</em></strong></blockquote><h3>The Journey: From Chaos to Simplicity</h3><h4>Step 1: Understanding Our Architecture</h4><p>Our setup consists of:</p><ul><li><strong>Frontend</strong>: React app built with Vite</li><li><strong>Backend</strong>: API server on port ****</li><li><strong>Nginx</strong>: Reverse proxy handling routing</li><li><strong>Jenkins</strong>: CI/CD pipeline</li><li><strong>VPS</strong>: Single server hosting everything</li></ul><p>💡<strong> The Key Insight</strong></p><p><strong>Nginx already handles API routing.</strong><br> That means the frontend doesn’t need to know backend URLs in production.</p><pre>server {<br>    server_name your-server.com;<br><br>    # Serve frontend<br>    location / {<br>        proxy_pass http://localhost:3000;<br>        ...<br>    }<br><br>    # Proxy API calls<br>    location /api/ {<br>        proxy_pass http://localhost:90**/;<br>        ...<br>    }<br>...</pre><h3>Step 2: One Dockerfile for All Environments</h3><p>Instead of maintaining separate Dockerfiles, I created a single, flexible one:</p><pre>FROM node:20-alpine AS builder<br>WORKDIR /app<br><br># Copy package files<br>COPY package.json package-lock.json ./<br>RUN npm install --legacy-peer-deps<br><br># Copy source code<br>COPY . .<br><br># Build argument for environment<br>ARG BUILD_MODE=production<br>RUN npm run build --mode=${BUILD_MODE}<br><br># Production stage<br>FROM nginx:alpine<br>COPY nginx.conf /etc/nginx/conf.d/default.conf<br>COPY --from=builder /app/dist /usr/share/nginx/html<br><br>EXPOSE 80<br>CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]</pre><p><strong>Key benefits:</strong></p><ul><li>Single file to maintain</li><li>Environment-specific builds via BUILD_MODE argument</li><li>Production-ready defaults</li></ul><h3>Step 3: Universal Nginx Configuration</h3><p>Instead of separate nginx configs, I created one optimized for all environments:</p><pre>server {<br>    listen 80;<br>    server_name _; // since server nginx handles it<br>    ...<br>}</pre><h3>Step 4: One docker-compose File</h3><p>A single docker-compose.yml with smart defaults:</p><pre>version: &quot;3.9&quot;<br>services:<br>  frontend:<br>    build:<br>      context: .<br>      dockerfile: Dockerfile<br>      args:<br>        BUILD_MODE: ${BUILD_MODE:-production}<br>    container_name: ${BUILD_MODE:-frontend}<br>    ports:<br>      - &quot;${PORT:-30**}:80&quot;<br>    restart: ${RESTART_POLICY:-always}</pre><h3>The Solution: One-Parameter Jenkins Pipeline</h3><p>Here’s where the magic happens. Instead of multiple parameters, I created a Jenkins pipeline controlled by a single choice:</p><pre>pipeline {<br>    agent any<br><br>    parameters {<br>        choice(<br>            name: &#39;BUILD_MODE&#39;,<br>            choices: [&#39;staging&#39;, &#39;uat&#39;, &#39;production&#39;],<br>            description: &#39;Environment (staging=development:30** | uat=uat:30** | production=production:30**)&#39;<br>        )<br>    }<br><br>    environment {<br>        BUILD_MODE = &quot;${params.BUILD_MODE}&quot;<br>        // Auto-assign ports based on environment<br>        PORT = &quot;${params.BUILD_MODE == &#39;staging&#39; ? &#39;30**&#39; :<br>                (params.BUILD_MODE == &#39;uat&#39; ? &#39;30**&#39; : &#39;30**&#39;)}&quot;<br>        // Auto-assign branches<br>        BRANCH_NAME = &quot;${params.BUILD_MODE == &#39;staging&#39; ? &#39;development&#39; :<br>                      (params.BUILD_MODE == &#39;uat&#39; ? &#39;uat&#39; : &#39;production&#39;)}&quot;<br>        RESTART_POLICY = &quot;always&quot;<br>    }<br><br>    stages {<br>        stage(&#39;Checkout&#39;) {<br>            steps {<br>                script {<br>                    checkout([$class: &#39;GitSCM&#39;,<br>                        branches: [[name: &quot;${BRANCH_NAME}&quot;]],<br>                        doGenerateSubmoduleConfigurations: false,<br>                        submoduleCfg: [],<br>                        userRemoteConfigs: [[<br>                            credentialsId: &quot;your-git-credentials&quot;,<br>                            url: &quot;https://your-repo-url.git&quot;<br>                        ]]<br>                    ])<br>                }<br>            }<br>        }<br><br>        stage(&#39;Cleanup Old Containers&#39;) {<br>            steps {<br>                script {<br>                    sh &quot;&quot;&quot;<br>                        if [ \$(docker ps -a -q -f name=${BUILD_MODE} | wc -l) -gt 0 ]; then<br>                            docker rm -f ${BUILD_MODE}<br>                        fi<br>                    &quot;&quot;&quot;<br>                }<br>            }<br>        }<br><br>        stage(&#39;Deploy&#39;) {<br>            ...<br>        }<br>    }<br>}<br></pre><h3>What this pipeline does automatically</h3><ul><li>Selects the correct branch</li><li>Assigns the right port</li><li>Builds with the correct mode</li><li>Names containers consistently</li><li>Deploys safely</li></ul><p>All from <strong>one parameter</strong>.</p><pre>### Environment Mapping<br><br>| Environment | Branch        | Port | Container    | Use Case        |<br>| ----------- | ------------- | ---- | ------------ | --------------- |<br>| Staging     | `development` | 30** | `staging`    | Feature testing |<br>| UAT         | `uat`         | 30** | `uat`        | User acceptance |<br>| Production  | `production`  | 30** | `production` | Live site       |</pre><h3>The Results: What This Achieves</h3><h3>Before vs After</h3><p><strong>Before:</strong></p><ul><li>6+ files to maintain (multiple Dockerfiles, docker-compose files, nginx configs)</li><li>3+ Jenkins parameters to remember</li><li>Manual branch and port management</li><li>High chance of human error</li></ul><p><strong>After:</strong></p><ul><li>3 core files (Dockerfile, docker-compose.yml, nginx.conf)</li><li>1 Jenkins parameter</li><li>Automatic everything</li><li>Zero configuration deployment</li></ul><h3>Deployment Process</h3><ol><li><strong>Developer</strong>: Push code to appropriate branch</li><li><strong>Jenkins</strong>: Select environment from dropdown</li><li><strong>Magic</strong>: Everything else happens automatically</li></ol><ul><li>Correct branch is checked out</li><li>Right build mode is used</li><li>Proper port is assigned</li><li>Container is named correctly</li></ul><h3>Environment Variable Strategy</h3><p>Local Development</p><pre># .env.development<br>VITE_API_BASE_URL=https://your-dev-api.com<br>VITE_API_AUTH_URL=http://your-auth-server:90**</pre><p>Production / Staging</p><pre># .env.staging / .env.production<br># No API URLs needed - nginx handles routing<br>VITE_ENV=staging<br>MODE=staging<br>GENERATE_SOURCEMAP=false</pre><p>The beauty is that production environments don’t need API URLs because nginx proxy handles all /api and /auth routing.</p><h3>Key Benefits</h3><h3>1. Extreme Simplicity</h3><p>One parameter controls everything.<br> No guesswork. No manual steps.</p><h3>2. Scalability</h3><p>New environments are easy to add.<br> Same process, same structure.</p><h3>3. Error Reduction</h3><p>No invalid parameter combinations.<br> Consistent naming and mapping.</p><h3>4. Developer Experience</h3><p>One-click deployments.<br> Faster feedback. Less stress.</p><h3>5. Maintainability</h3><p>Single source of truth.<br> Easy to understand and modify.</p><h3>Potential Drawbacks (and Solutions)</h3><p><strong>Limited flexibility</strong><br> → Add an optional branch override when needed</p><p><strong>Scaling beyond 5+ environments</strong><br> → Replace ternary logic with a config map</p><p><strong>Debugging pipeline logic</strong><br> → Keep environment mappings well documented</p><h3>Conclusion</h3><p>This approach transformed our deployment process from a complex, error-prone manual task into a simple, one-click operation. By embracing convention over configuration and leveraging Jenkins parameters effectively, we achieved:</p><ul><li><strong>90% reduction</strong> in deployment-related files</li><li><strong>Zero configuration</strong> deployments</li><li><strong>Consistent</strong> environment management</li><li><strong>Happy developers</strong> who can focus on code instead of DevOps</li></ul><p>The key insight was recognizing that most deployment complexity comes from trying to handle every possible scenario upfront. Instead, we built a system that handles 80% of our needs perfectly and can be extended when necessary.</p><p><em>Have you implemented something similar? I’d love to hear about your deployment simplification stories in the comments!Follow me for more DevOps simplification tips and React deployment strategies!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f84383b411a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>