SwiftDeploy is a CLI tool that deploys a containerised app using a single manifest.yaml file. You edit the manifest, the tool handles everything else.
- Docker
- Docker Compose
- Python 3
- curl
app/- FastAPI app, Dockerfile, and requirements.txttemplates/- Nginx and Docker Compose templatesmanifest.yaml- single source of truth for the deploymentswiftdeploy- the CLI tool
Fork this repository by clicking the Fork button on the top right of this page:
https://github.com/Dorcas-BD/swiftdeploy
Then clone your forked copy:
git clone https://github.com/your-usernamee/swiftdeploy.git
cd swiftdeployBuild the Docker image:
cd app
docker build -t swift-deploy-1-node:latest .
cd ..Make the CLI executable:
chmod +x swiftdeployGenerates nginx.conf and docker-compose.yml from the templates using values in manifest.yaml.
./swiftdeploy initRuns 5 checks before you deploy. Stops and tells you what failed if anything is wrong.
./swiftdeploy validateWhat it checks:
- manifest.yaml exists and is valid YAML
- All required fields are filled in
- Docker image exists locally
- Nginx port is not already in use
- nginx.conf has been generated
Runs init, starts the stack, and waits until the app is healthy before returning.
./swiftdeploy deploySwitches the app between stable and canary mode without taking everything down.
./swiftdeploy promote canary
./swiftdeploy promote stableStops and removes all containers, networks, and volumes.
./swiftdeploy teardownTo also delete the generated config files:
./swiftdeploy teardown --clean| Endpoint | Method | Description |
|---|---|---|
| / | GET | Returns mode, version, and current timestamp |
| /healthz | GET | Returns status and how long the app has been running |
| /chaos | POST | Simulates failures, only works in canary mode |
Slow responses:
curl -X POST http://localhost:8080/chaos \
-H "Content-Type: application/json" \
-d '{"mode": "slow", "duration": 5}'Random errors:
curl -X POST http://localhost:8080/chaos \
-H "Content-Type: application/json" \
-d '{"mode": "error", "rate": 0.5}'Back to normal:
curl -X POST http://localhost:8080/chaos \
-H "Content-Type: application/json" \
-d '{"mode": "recover"}'stable - normal production mode
canary - test mode, enables the chaos endpoint and adds an X-Mode: canary header to every response
./swiftdeploy deploy - (X2)
curl http://localhost:8080/
./swiftdeploy promote canary./swiftdeploy statuscurl -X POST http://localhost:8080/chaos \
-H "Content-Type: application/json" \
-d '{"mode": "error", "rate": 0.5}'
for i in {1..20}; do curl -s http://localhost:8080/ > /dev/null; done./swiftdeploy promote stablecurl -X POST http://localhost:8080/chaos \
-H "Content-Type: application/json" \
-d '{"mode": "recover"}'
for i in {1..500}; do curl -s http://localhost:8080/ > /dev/null; done
./swiftdeploy promote stable