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

推荐订阅源

Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
V
V2EX
博客园 - 叶小钗
雷峰网
雷峰网
小众软件
小众软件
量子位
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
G
Google Developers Blog
博客园_首页
博客园 - Franky
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享

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
Building a Self-Deploying Infrastructure Tool with OPA Po...
CHIMA_NIGERI · 2026-05-07 · via DEV Community

Building a Self-Deploying Infrastructure Tool with OPA Policy Guards
What I Built and Why....

Author CHIMA_THE_NIGERIAN_SUPERMAN

For HNG Stage 4, I built SwiftDeploy — a CLI tool that turns a single YAML manifest into a fully running web application with Nginx, Docker containers, and Open Policy Agent security gates.

The problem at hand: Traditional DevOps requires writing multiple config files by hand, manually checking if the environment is safe, and hoping nothing breaks during deployment.

The solution i worked on: One manifest file describes everything. The tool generates all configs, checks policies automatically, and refuses to deploy if conditions aren't met.

How the Manifest Works
The manifest.yaml is the only file I edit. It declares:

yaml
services:
image: swift-deploy-1-node:latest
port: 3000
mode: stable

nginx:
image: nginx:latest
port: 8080

From this single file, swiftdeploy init generates:

nginx.conf with reverse proxy, JSON logging, and error pages

docker-compose.yml with health checks, networks, and volumes

If you delete the generated files, they regenerate exactly the same way. The manifest is the single source of truth, i call the omni truth lol

The Policy Brain: Open Policy Agent

The coolest part is the OPA sidecar. Instead of hardcoding "if disk < 10GB, don't deploy" in the CLI, I wrote it as a Rego policy:

rego
allow if {
disk_free_gb > 10
cpu_load < 2.0
}

The CLI asks OPA: "Should I deploy?" OPA answers with reasoning — not just yes/no, but exactly why. If OPA is unreachable, the CLI fails safely instead of crashing.

The Observability Eyes: Prometheus Metrics

Every request is tracked with counters by method, path, and status code. Latency is recorded in histogram buckets.
The /metrics endpoint serves everything in Prometheus format.

The live dashboard (swiftdeploy status) scrapes these metrics every 3 seconds and shows real-time policy compliance.

Chaos Testing: Breaking Things on Purpose
The canary mode has a /chaos endpoint that lets you inject failures:

slow mode: Responses take N seconds

error mode: 50% of requests return 500 errors

recover: Cancels all chaos

When I activated error mode, the pre-promote gate blocked promotion because the error rate exceeded the 1% threshold. The audit report recorded every violation.

What I Learned?

Declarative configuration is powerful — One file generates an entire stack

Policy-as-code prevents mistakes — OPA catches problems before they reach users

Observability matters — Without metrics, you're deploying blind

Always whitelist your own IP — I learned this the hard way in Stage 3!

Try It Yourself
The project is open source at github.com/icode-py/swiftdeploy.

git clone https://github.com/icode-py/swiftdeploy.git
cd swiftdeploy
pip install pyyaml jinja2 psutil
cd app && docker build -t swift-deploy-1-node:latest . && cd ..
python swiftdeploy deploy
curl http://localhost:8080/

Thank you