Skip to content

dev-dma/swiftdeploy4b

Repository files navigation

SwiftDeploy

A declarative deployment CLI that generates all infrastructure config from a single manifest.yaml and manages the full container lifecycle.

Prerequisites

  • Docker Desktop with WSL2 integration enabled
  • Python 3.12+
  • pip packages: pip install pyyaml jinja2 --break-system-packages

Project Structure

``` swiftdeploy-project/ ├── manifest.yaml ← single source of truth (only file you edit) ├── swiftdeploy ← CLI tool ├── Dockerfile ← builds the API image ├── app/ │ ├── main.py ← Flask API service │ └── requirements.txt ├── templates/ │ ├── nginx.conf.j2 ← Nginx template │ └── docker-compose.yml.j2 └── README.md ```

Quick Start

1. Build the image

```bash docker build -t swift-deploy-1-node:latest . ```

2. Deploy the full stack

```bash ./swiftdeploy deploy ```

3. Test it

```bash curl http://localhost:8080/ curl http://localhost:8080/healthz ```

Subcommand Walkthrough

init

Parses manifest.yaml and generates nginx.conf + docker-compose.yml ```bash ./swiftdeploy init ```

validate

Runs 5 pre-flight checks before deployment:

  1. manifest.yaml exists and is valid YAML
  2. All required fields present and non-empty
  3. Docker image exists locally
  4. Nginx port not already bound
  5. nginx.conf syntax is valid ```bash ./swiftdeploy validate ```

deploy

Runs init → validate → starts stack → waits for health (60s timeout) ```bash ./swiftdeploy deploy ```

promote

Switches deployment mode with rolling service restart ```bash ./swiftdeploy promote canary # enables chaos endpoint + X-Mode header ./swiftdeploy promote stable # rolls back to stable ```

teardown

Removes all containers, networks, and volumes ```bash ./swiftdeploy teardown # stops stack ./swiftdeploy teardown --clean # also deletes generated configs ```

API Endpoints

Method Path Description
GET / Welcome message, mode, version, time
GET /healthz Status + uptime in seconds
POST /chaos Inject chaos (canary mode only)

Chaos modes (canary only)

```bash

Slow mode — sleep N seconds per request

curl -X POST http://localhost:8080/chaos
-H "Content-Type: application/json"
-d '{"mode": "slow", "duration": 3}'

Error mode — return 500 on ~50% of requests

curl -X POST http://localhost:8080/chaos
-H "Content-Type: application/json"
-d '{"mode": "error", "rate": 0.5}'

Recover — cancel all chaos

curl -X POST http://localhost:8080/chaos
-H "Content-Type: application/json"
-d '{"mode": "recover"}' ```

Design Decisions

  • Non-root container — app runs as appuser with all capabilities dropped
  • Image size — 186MB (well under 300MB limit)
  • Port isolation — app port 3000 never exposed; all traffic via Nginx on 8080
  • Single source of truth — manifest.yaml drives everything; no manual config
  • Named volumes — logs persist across container restarts

About

SwiftDeploy - DevOps Stage 4A & 4B

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages