惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
Y
Y Combinator Blog
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
S
SegmentFault 最新的问题
IT之家
IT之家
Recent Announcements
Recent Announcements
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
阮一峰的网络日志
阮一峰的网络日志
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
WordPress大学
WordPress大学
博客园 - Franky
L
LangChain Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
博客园 - 叶小钗
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
雷峰网
雷峰网
腾讯CDC
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Help Net Security
Help Net Security
C
Check Point Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News and Events Feed by Topic
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
博客园 - 聂微东
A
Arctic Wolf
H
Heimdal Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
The Exploit Database - CXSecurity.com
C
Cyber Attacks, Cyber Crime and Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I Built a Tool That Builds My Infrastructure — Here's How It Went
Hezekiah Umo · 2026-05-06 · via DEV Community

I Built a Tool That Builds My Infrastructure — Here's How It Went

A brutally honest account of building SwiftDeploy for the HNG14 Stage 4A DevOps challenge


When I first read the Stage 4A task brief, one line jumped out at me:

"Most DevOps tasks ask you to configure infrastructure manually — this one asks you to build the tool that does it for you."

That single sentence changed how I approached the entire challenge. This wasn't about setting up servers or writing config files by hand. It was about building something that does all of that for you, from a single source of truth.

This is the story of how I built SwiftDeploy — and every wall I hit along the way.


What Is SwiftDeploy?

SwiftDeploy is a declarative deployment CLI tool. You describe your entire infrastructure in a single manifest.yaml file, and the tool generates your Nginx config, Docker Compose file, manages your container lifecycle, and keeps your stack healthy.

The stack consists of:

  • A FastAPI Python service that runs in either stable or canary mode
  • An Nginx reverse proxy that routes all traffic, logs every request, and returns JSON error responses
  • A CLI tool written in Python with five subcommands: init, validate, deploy, promote, and teardown
  • Everything generated from Jinja2 templates — no manually written config files allowed

The grader would delete my generated files and re-run swiftdeploy init to verify everything regenerates correctly. If the tool broke, the stack broke. No shortcuts.


The Architecture

Before writing a single line of code, I mapped out how everything would connect:

manifest.yaml  →  swiftdeploy init  →  nginx.conf + docker-compose.yml
                                              ↓
                                    docker-compose up
                                              ↓
                              [nginx:8080] → [app:3000]

Enter fullscreen mode Exit fullscreen mode

The manifest.yaml is the only file a human ever edits. Everything else is derived from it. That constraint is what makes the tool interesting — and what made debugging it so painful at times.


Building the API Service

The API service is a FastAPI application with three endpoints:

GET / returns a welcome message including the current mode, version, and server timestamp.

GET /healthz returns a liveness check with process uptime in seconds — used by Docker's health check system to determine if the container is ready to serve traffic.

POST /chaos is the interesting one. It's only active in canary mode and lets you simulate degraded behaviour: slow responses, random 500 errors, or a full recovery. This is the kind of endpoint that makes canary deployments genuinely useful — you can test how your system behaves under failure before rolling it out to everyone.

Canary mode also adds an X-Mode: canary header to every response, so you can always tell which mode the service is running in just by inspecting the headers.


Building the CLI

The CLI is a single Python script with no external framework — just argparse-style argument handling, PyYAML for parsing the manifest, and Jinja2 for rendering templates.

The five subcommands each have a clear responsibility:

init reads the manifest and renders both templates. Simple, fast, deterministic.

validate runs five pre-flight checks before anything is deployed. It checks that the manifest exists and is valid YAML, that all required fields are present, that the Docker image exists locally, that the Nginx port is free on the host, and that the generated nginx.conf passes a syntax check.

deploy chains init and validate together, then brings up the stack and blocks until health checks pass — or times out after 60 seconds.

promote is the most complex command. It updates the mode field in manifest.yaml in-place, regenerates docker-compose.yml with the new MODE environment variable, restarts only the app container (not nginx), and then confirms the new mode is active by hitting /healthz.

teardown brings everything down cleanly. With --clean, it also deletes the generated config files.


The Challenges — And There Were Many

I want to be honest here. This project did not go smoothly. Here is every wall I hit, in order.

The folder was named wrong

My templates folder was named template — without the s. The CLI was looking for templates/nginx.conf.j2 and kept throwing a TemplateNotFound error. I spent more time than I'd like to admit staring at that error before noticing the missing letter.

The file was named wrong too

Once the folder name was fixed, the nginx config template was named nginx.config.j2 instead of nginx.conf.j2. Config versus conf — four characters making the whole thing fail silently.

Windows doesn't have chmod

Running chmod +x swiftdeploy in PowerShell throws an error. On Windows, you just run python swiftdeploy <command> directly — no permissions needed. This caught me off guard because the instructions assumed a Linux environment.

The Dockerfile wasn't saving

This one was the most frustrating. I edited the Dockerfile in VSCode multiple times, but the changes weren't persisting. The tab showed unsaved changes that I kept missing. Every docker build was using the old version of the file, and pip install was installing nothing because the COPY paths were wrong.

The fix was bypassing VSCode entirely and writing the file content directly from the PowerShell terminal using Out-File. Once the file was written programmatically, the builds started working correctly.

app/requirements.txt was empty

The requirements.txt inside the app/ folder was created but had no content — completely empty. Because pip install on an empty file succeeds without error, the container built cleanly but had no packages installed. fastapi and uvicorn were both missing, and the container crashed on startup with No module named uvicorn.

I only caught this by running docker run --rm swift-deploy-1-node:latest pip list and seeing nothing but pip in the output. The fix was writing the dependencies directly from the terminal:

"fastapi==0.111.0`nuvicorn[standard]==0.29.0" | Out-File -FilePath app\requirements.txt -Encoding utf8

Enter fullscreen mode Exit fullscreen mode

Docker kept caching broken layers

Even after fixing the Dockerfile and the requirements file, Docker kept serving the old cached image. The fix was force-removing the image entirely and rebuilding with --no-cache:

docker rmi -f swift-deploy-1-node:latest
docker build --no-cache -t swift-deploy-1-node:latest .

Enter fullscreen mode Exit fullscreen mode

Port 3000 was already allocated

My Stage 2 project containers were still running in the background and had port 3000 allocated. Every attempt to test the app container on port 3000 failed with Bind for 0.0.0.0:3000 failed: port is already allocated. The fix was simply stopping the Stage 2 frontend container temporarily.

Nginx upstream validation broke pre-deployment

The validate command tests nginx syntax by spinning up a temporary nginx container. But before the stack is running, the app hostname doesn't exist on any Docker network, so nginx reports host not found in upstream. This looks like a failure but is completely expected — the config is syntactically correct, the hostname just doesn't resolve yet.

The fix was updating the validate logic to treat this specific error as a pass, not a failure. Any other nginx error would still cause validation to fail.


The Moment It Worked

After all of that, here is what the final deploy output looked like:

▶  swiftdeploy deploy
  ✔  nginx.conf generated
  ✔  docker-compose.yml generated
  ✔  manifest.yaml exists and is valid YAML
  ✔  All required manifest fields present and non-empty
  ✔  Docker image exists locally: swift-deploy-1-node:latest
  ✔  Nginx port 8080 is free
  ✔  nginx.conf is syntactically valid
✔  All checks passed — stack is ready to deploy
  ➜  Bringing up the stack…
  ✔  Container swiftdeploy-app-1    Healthy
  ✔  Container swiftdeploy-nginx-1  Started
  ✔  Stack is healthy → http://localhost:8080

Enter fullscreen mode Exit fullscreen mode

And hitting http://localhost:8080 in the browser returned:

{
  "message": "Welcome to SwiftDeploy API — running in stable mode",
  "mode": "stable",
  "version": "1.0.0",
  "timestamp": "2026-05-02T17:44:59.804140+00:00"
}

Enter fullscreen mode Exit fullscreen mode

Then promoting to canary:

▶  swiftdeploy promote canary
  ✔  manifest.yaml updated → mode: canary
  ✔  docker-compose.yml regenerated
  ➜  Restarting app container…
  ✔  Service healthy after promote → http://localhost:8080/healthz
  ➜  Active mode confirmed: canary

Enter fullscreen mode Exit fullscreen mode

That moment — seeing Active mode confirmed: canary in the terminal — felt genuinely satisfying after everything it took to get there.


What I Learned

Declarative infrastructure is powerful but unforgiving. When the manifest is the single source of truth, every typo and every wrong path has consequences. But when it works, the elegance is undeniable — one file describes everything.

Always verify your file saves. On Windows especially, VSCode unsaved changes are easy to miss. When something isn't working despite your edits, verify the file content from the terminal before assuming the code is wrong.

Docker caching is a double-edged sword. It speeds up builds dramatically, but when you're debugging image content, it can hide your fixes behind stale layers. --no-cache should be your first instinct when something is inexplicably wrong.

Empty files fail silently. An empty requirements.txt is not an error — it's a valid file with no dependencies. Always verify what's actually inside your files, not just that they exist.

Pre-flight validation saves deployments. The five checks in the validate command caught real problems before they reached production. The nginx upstream check in particular required nuanced handling — not every nginx error is a real error.


Final Thoughts

SwiftDeploy is not a perfect tool. But it works. It deploys a full stack from a single manifest, handles canary deployments with a single command, and validates itself before touching anything.

More importantly, every challenge I hit while building it taught me something real about how infrastructure tools work — and why the details matter so much.

If you're working through HNG14 or any similar programme, my advice is simple: document your failures as carefully as your successes. The graders can tell the difference between someone who got fortunate and someone who actually understands what they built.

Good fortune for you out there. 🚀


Here's the repo incase it interest you to clone and replicate
Github:https://github.com/ntonous/hng14-stage4-taask.git

Built with Python, FastAPI, Nginx, Docker,Jinja2 and a lot of patience.
HNG14 Stage 4A — DevOps Track