Ir al contenido principal

Zero Ops on Mac Mini M4: Native CI/CD for C# APIs

Advanced DevOps Guide

Zero Ops on Mac Mini M4: Native CI/CD for C# APIs

Launchd Agents Automated Deploy Git-Driven
Automated deployment flow for Mac Mini

Transforming your Mac Mini into a self-healing, auto-deploying production server.

"The goal is simple: Git Push and forget. No manual terminals, no complex Docker layers—just pure macOS native resilience."

1 The Core: Deployment Script

We create a dedicated deploy.sh script. This "heart" of the system handles compiling the ARM64 binary and restarting the service.

Script Location: ~/code/csharp/be-real-doctor-api/deploy.sh
#!/bin/bash

# 1. Explicitly define PATH so Launchd can find git and dotnet
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet"

PROJECT_DIR="/Users/ismael/code/csharp/repo-name"
PUBLISH_DIR="$PROJECT_DIR/src/publish"
PLIST_PATH="$HOME/Library/LaunchAgents/com.appname.api.plist"

# 2. Use the absolute path for dotnet (adjusted based on 'which dotnet' output)
DOTNET_BIN="/usr/local/share/dotnet/dotnet"

echo "馃殌 Starting automatic deployment..."
cd "$PROJECT_DIR/src"

# Execute publish using the absolute path
$DOTNET_BIN publish -c Release -r osx-arm64 --self-contained false -o "$PUBLISH_DIR"

if [ $? -eq 0 ]; then
    # 3. Restart the service
    launchctl unload "$PLIST_PATH" 2>/dev/null
    launchctl load "$PLIST_PATH"
    echo "✅ AppName updated and running."
else
    echo "❌ Build failed. Check for missing SDK or code errors."
    exit 1
fi

Don't forget to run: chmod +x deploy.sh

2 Resilience: The .plist Agent

Instead of using .zshrc, we use a Launch Agent. This ensures the API runs 24/7, restarts on crashes, and boots automatically with the Mac.

File: ~/Library/LaunchAgents/com.berealdoctor.api.plist

Set ASPNETCORE_URLS to http://0.0.0.0:5000 to allow external access within your network, and set KeepAlive to true for 100% uptime.

Initialize with: launchctl load [path_to_plist]

3 The Brain: Auto-Git Watcher

To achieve true Zero Ops, we set up a second agent that monitors your repository every 60 seconds. If it detects a change on GitHub, it pulls and triggers the deploy script.

CI/CD Logic:

git fetch origin && [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ] && git pull && ./deploy.sh

This command compares your local HEAD with the remote. It only triggers a build when new code is actually present.

4 Why This is Superior

  • Zero Terminal Dependency: No need to keep a terminal window open or use tools like fswatch.
  • Git-Driven: Your only action is git push from your development laptop.
  • Native Resilience: If the Mac Mini restarts after a power outage, the agents boot up automatically.

Zero Ops Achieved

Your Mac Mini M4 is now a professional-grade automated server.

PUSH CODE. STAY CALM.

Comentarios

Entradas populares de este blog

Bye GitHub Copilot: Setup Your Own Local AI

Next-Gen Development Bye GitHub Copilot: Setup Your Own Local AI C# Software Development 6 min read Coding at 30,000 feet: Independent, private, and powerful. "Picture this: You’re on a flight to Mallorca . You open your laptop, the cabin is quiet, and inspiration strikes. But there is no Wi-Fi, and your cloud-based AI tools are useless. By hosting your own LLM, you don't just gain privacy: you gain operational freedom ." Worried about code privacy or rising subscription costs? In 2026, the era of local LLMs has arrived. Setting up a local environment allows you to use specialized models like DeepSeek or Qwen which, in many cases, outperform generic models in specific programming tasks, offering a precision that cloud-based Copilot simply cannot match offline. 1 Step 1: The Brain (LM Studio) Model Selection Search ...

The 8GB VRAM Challenge: Optimizing Local AI

Hardware & Performance The 8GB VRAM Challenge: Optimizing Local AI Technical Review Real Hardware Benchmarks Power vs. Limits: Running LLMs on the new RTX 5070 Mobile architecture. "Building a local AI powerhouse in a laptop is a game of balance. With an Intel Core Ultra 9 and 64GB of RAM , the processing floor is high, but the 8GB VRAM on the RTX 5070 is the ultimate gatekeeper. Here is the stable, no-filler configuration for coding, reasoning, and technical chat." The Hardware Specs GPU RTX 5070 8GB VRAM (Bottleneck) RAM 64GB DDR5 System Overflow Ready CPU Ultra 9 285H Top-Tier Processing 1 Model Selection Strategy Size vs. Quantization (The Sweet Spot) ✅ 3B – 7B Models: Gold standard. Q5_K_M (app...

Intellectual Property and Git: Avoiding AI Co-authored-by

Software Engineering Guide Intellectual Property and Git: Avoiding AI Co-authored-by Due Diligence AI Agents Git Hooks Maintaining a 100% human history is key to the legal health of your source code. "A golden rule in modern development: the commit message should reflect 'why' the change was made for the business, never 'how' or which tools were used to write it. " 1 Legal Context: Why the Concern? More and more startups and independent developers are facing an invisible problem: patent and copyright offices in the US and EU have determined that AI cannot hold copyrights . Only human creation is protectable. The Danger in Audits (Due Diligence): When a startup seeks investment or is about to be acquired, it undergoes a strict code audit. If the Git history shows bots as co-authors, investors can argue the ...