A lightweight, production-ready Ruby web application built with Sinatra.
This project demonstrates:
- A simple HTTP service
- Containerization using Docker
- Deployment using NIFE
It is suitable for:
- Learning Sinatra fundamentals
- Understanding containerized deployments
- Practicing cloud deployment workflows
1. HTTP Request (GET /)
2. Handled by Sinatra route
3. Read NAME from environment
4. Generate greeting
5. Return response
GET / → Returns greeting message
Make sure you have the following installed:
- Ruby (3.0+)
- RubyGems
- Bundler
- Git
git clone https://github.com/nifetency/ruby-example.git
cd ruby-examplegem install sinatra rackup pumaOr using Gemfile:
bundle installruby server.rbVisit:
http://localhost:8080
Expected output:
Bonjour world!
Set a custom name using environment variables:
# macOS/Linux
NAME=David ruby server.rb
# Windows PowerShell
$env:NAME="David"; ruby server.rbOutput:
Bonjour David!
docker build -t ruby-example-app .
docker run -p 8080:8080 -e NAME=Alice ruby-example-appDeploy your application using the NIFE platform:
Deployment flow:
Source → Build → Resources → Review → Deploy
Prerequisite: Ensure a workload (Deployment, CronJob, or StatefulSet) exists.
docker build -t ruby-example-app .
docker tag ruby-example-app <username>/ruby-example-app:latest
docker push <username>/ruby-example-app:latest- Source: Docker Image
- Registry: Docker Hub
- Image:
<username>/ruby-example-app:latest - Tag:
latest
- Internal Port:
8080 - External Port:
80
Optional environment variables:
| Key | Value |
|---|---|
| NAME | Ruby |
| RACK_ENV | production |
- Region: e.g.,
ap-south-1 - Resource Type: CPU
Recommended settings:
- CPU Request:
250m - Memory Request:
512MB - CPU Limit:
500m - Memory Limit:
1GB
- Strategy: Rolling
- Workload: Deployment
- Routing Policy: Latency
- Replicas: 1–2
Click Deploy.
- Source: Git Repository
- Provider: GitHub
- Branch:
main
- Internal Port:
8080 - External Port:
80
Enable:
Auto-Dockerize with Runtime
NIFE automatically performs:
- SAST
- SCA
- Container scan
- IaC scan
Resolve any critical issues before proceeding.
Use the recommended configuration above and deploy.
You can deploy the application using the nifectl CLI.
https://docs.nife.io/Quick-Start/Nifectl
- Type
cmdin the address bar
OR - Right-click → Open in Terminal
nifectl --helpnifectl auth loginnifectl initProvide:
- Application name
- Organization
- Repository URL
- Branch (
main)
- Deployment Type: Deployment
- Resource Type: CPU
- Replicas: 1
Ports:
- Internal:
8080 - External:
80
nifectl deployExample:
IND - Mumbai
Monitor logs for:
- Validation
- Build
- Deployment
https://<your-nife-url>
| Dependency | Purpose |
|---|---|
| Ruby | Runtime |
| Sinatra | Web framework |
| Rack | Interface layer |
| Puma | Web server |
| Variable | Description | Default |
|---|---|---|
| NAME | Greeting name | World |
| Issue | Solution |
|---|---|
| Port already in use | Change port or stop process |
| Docker not running | Start Docker |
| Image pull error | Ensure image is public |
| Build fails | Verify configuration |
| No workloads | Create workload in NIFE |
| Deployment blocked | Resolve security issues |
This repository is maintained by Nifetency as a sample deployment project for Nife.io.
If this repository is derived from an upstream example, proper credit should be given to the original author.
This project is licensed under the MIT License.
- Original Repository: https://github.com/nifetency/ruby-example
- NIFE Platform: https://nife.io/