A minimal Swift web application using the Vapor framework that serves a simple "Hello, World!" page, designed to be deployed using Disco.
- Simple "Hello, World!" response at
/
- Health check endpoint at
/health
- Built with Swift's modern concurrency (async/await)
- Optimized for deployment with Disco
- Minimal dependencies and lightweight structure
- Swift 5.10+ - Install Swift
- Disco CLI - Install Disco
- Server with SSH access (for deployment)
- Domain name (for deployment)
git clone <your-repo-url>
cd disco-example-swift-vapor-site
swift package resolve
swift run App
The server will start on http://localhost:8080
. You should see:
http://localhost:8080/
→ "Hello, World!"http://localhost:8080/health
→{"status": "ok"}
- Server Setup: You need a server you can SSH into (VPS from Hetzner, Digital Ocean, or even a Raspberry Pi)
- Domain Name: Register a domain with providers like Porkbun, Namecheap, or easydns.com
- Disco Installation: Install Disco on your server following the documentation
- Add your project to Disco:
disco projects:add \
--name swift-hello-world \
--github yourusername/disco-example-swift-vapor-site \
--domain your-domain.com
- Deploy by pushing to GitHub:
git add .
git commit -m "Initial commit"
git push origin main
Your app will be automatically built and deployed! 🚀
# View deployment logs
disco deploy:output --project swift-hello-world
# Check project status
disco projects:list
disco-example-swift-vapor-site/
├── Package.swift # Swift Package Manager configuration
├── Sources/
│ └── App/
│ └── main.swift # Main application entry point
├── disco.json # Disco deployment configuration
├── Dockerfile # Container configuration for deployment
├── README.md # This file
└── .gitignore # Git ignore rules
PORT
- Server port (defaults to 8080)
The disco.json
file configures the deployment:
{
"version": "1.0",
"services": {
"web": {
"port": 8080
}
}
}
Edit Sources/App/main.swift
to add new routes:
app.get("about") { req async -> String in
"About page"
}
Test your application locally:
# Run the app
swift run App
# In another terminal, test endpoints
curl http://localhost:8080/
curl http://localhost:8080/health
- Ensure you have Swift 5.10+ installed:
swift --version
- Clear package cache:
swift package clean
- Resolve dependencies:
swift package resolve
- Check deployment logs:
disco deploy:output --project your-project-name
- Verify your
disco.json
configuration - Ensure your server meets the system requirements
- Cost Effective: Host multiple sites for a single fee instead of paying per project
- Lightning Fast: Deployments in seconds, not minutes
- Simple Setup: Push to GitHub and your changes go live automatically
- Own Your Infrastructure: No vendor lock-in, deploy to your own servers
This project is provided as an example and is free to use and modify.