Page 3 of 5

Architecture Deep Dive

Understand how the inner components of CICD connect, secure, run, and monitor your deployments.

Under the Hood

CICD operates as a single, lightweight orchestrator. It manages the entire process from accepting incoming git push webhooks to downloading dependencies, building, sandboxing, and tailing logs of multiple applications.

CICD Architecture Pipeline

Visual flow of the CICD Deployment Pipeline

1. The Deployment Pipeline

Every time a commit is pushed to your Git repository, the following step-by-step pipeline executes automatically:

1

Webhook POST & Security Handshake

Your Git host (GitHub/GitLab) sends a JSON POST payload to the orchestrator listening port (default: 9641). If a --webhook-secret was set, CICD verifies the payload authenticity using the X-Hub-Signature-256 header and a local HMAC-SHA256 handshake. Unauthorized requests are instantly rejected.

2

Project Mapping & Branch Filter

CICD looks up the project in its local SQLite database (located at the hardcoded path /etc/cicd/data/cicd.db) using the incoming repository URL. If found, it validates the payload branch against the configured branch (e.g., refs/heads/main). Mismatched branches are safely ignored.

3

Pin Check Bypass

If the project has been "pinned" to a specific commit (using the dashboard or cicd pin), CICD records the new commit in the database history but skips starting the build pipeline to protect your active environment.

4

Queue Enqueueing (First-In, Single-Active)

To avoid race conditions and CPU thrashing, CICD has a per-project deployment queue. If a deployment is already running for a project, the new deployment is placed in a single-slot buffer. If multiple new commits arrive while a build is running, intermediate commits are discarded and only the latest commit wins.

5

Sync Repository (Safe Pull)

CICD changes directory to the project's sandboxed path, resets tracked changes to HEAD to clear any local modifications, fetches the latest commits, and resets hard to the origin branch tip.

6

Install & Download Phase

If .cicd/install.sh exists, the orchestrator checks its SHA256 hash. If it matches the previously run hash, it is skipped. If not, it grants temporary, limited NOPASSWD sudo access to the service user, executes the install script with a timeout (default 30 min), and updates the cached hash.

7

Run & Compilation Phase

CICD detects if any pre-existing process is listening on your application's port and kills it to prevent port binding collisions. It then starts the application via .cicd/run.sh under the sandboxed service user context. The compilation/build steps (like npm run build or go build) run inside this phase, ensuring new code gets built on every webhook pull.

8

Post-Deploy Health Check & Auto-Rollback

CICD waits for 15 seconds to let the application stabilize. It then executes .cicd/health.sh (or verifies the PID/restarts if no script is present). If the check passes, the deployment is marked success. If it fails, CICD automatically rolls back the environment to the previous stable commit.

2. Security & Privilege Sandboxing

🔒 Production Security Sandboxing

CICD never runs your application code as root. Running untrusted web hooks as root opens severe remote code execution (RCE) vectors.

To keep your VPS safe, CICD implements a strict privilege-dropping system model:

3. Real-Time Telemetry & Watchdogs

Observability in the Command Center is powered by real-time streams:

4. Fleet Sync via MongoDB Atlas

Managing multiple VPS servers? Simply configure a shared MongoDB Atlas connection string:

← The .cicd Folder Next: CLI Reference →