deploy.sh
is a high-performance, zero-fluff Bash deployment tool built for developers who like speed, control, and clarity. Tested in real production environments, it's capable of deploying any app to any number of remote servers over SSH, with built-in configuration management, service control, and setup routines.
🧪 Tested and used successfully in production on two real-world apps.
- ✅ Domain/IP validation with optional DNS checks
- ✅ Auto-setup mode with support for
npm install
- ✅ Service restarts post-deployment
- ✅ Remote archiving + versioning
- ✅ Colorful and friendly terminal UX
- ✅ Safe prompts, countdown before deployment
- ✅ Extensible config system
- ✅ Self-validating CLI flags
- ✅ Failsafe traps for error handling
This script automates the end-to-end deployment process for web apps. It does the following:
- Parses CLI arguments or prompts for project details
- Validates server IPs/domains
- Archives the project locally
- Transfers the archive to remote servers
- Sets up remote directory structure and services
- Optionally runs a one-time setup with
npm install
- Restarts specified services
- Keeps versioned archives for rollback safety
bash deploy.sh [options]
Flag | Description |
---|---|
--type=domain|ip |
Deployment target type |
--servers=... |
Comma-separated list of IPs or domains |
--project=name |
Name of the project to deploy |
--config=path/to/file |
Path to optional .env config |
--services=... |
Comma-separated list/array of services to restart |
--setup=full|only |
Only run setup (no deployment) |
--npm |
Do npm install in setup |
--help |
Show help |
--rollback=number |
Rollback to a specific version |
bash deploy.sh \
--type=ip \
--servers=[192.168.1.2,192.168.1.3] \
--project=my-app \
--services=my-app.service,nginx \
--setup=full \
--npm
You can pass a .env
config using --config=config.env
. Supported variables:
SERVERS="myserver.com,api.myserver.com"
PROJECT_NAME=my-app
SERVICES="my-app.service,nginx" (Not recommended)
DEPLOY_DIR="/var/www/my-app"
LOG_FILE="/var/log/deploy.log"
TYPE="domain"
NODE_HOME="./api" (This is where your node app is. Always use a relative path)
If you just want to initialize the remote server without deploying code:
./deploy.sh --servers=[api1.myserver.com,api2.myserver.com] --services=[nginx,mariadb] --setup=full --npm
./deploy.sh --config=deploy.env --setup=full --npm
./deploy.sh --help
# and so on...
- Countdown before any deployment begins
- Validation of server type, services, and IPs/domains
- Prevents accidental overwrites or misdeployments
- Color-coded output for easy parsing
- Traps any errors and gives meaningful messages
The script automatically keeps old versions of your app in releases/
folder on the remote server. You can manually roll back by extracting an older archive or do:
deploy.sh --config=deployment/deploy.conf --services=[nginx] --rollback=3 # Rollback to the 3rd last version
This will extract the 3rd last version of the archive in the releases/
folder and make it the current version.
bash
scp
,ssh
tar
host
(auto-installsdnsutils
if not found)
This script has been tested and successfully used to deploy two real-world applications with different services and environments. One of them is Libly, an open-source project that helps you manage your library. Visit Libly to check out the project. The other is a closed-source project, but you can find the live app at Topically.
- Link the script to a bin directory in your $PATH for convenience:
chmod +x deploy.sh sudo ln -s ./deploy.sh /usr/local/bin/deploy # You can now run it with just `deploy`. eg: `deploy --help`
- Add a
deploy.env
file for each project and reuse the script globally. - Run with
--help
to get a clean usage guide.
Made with love by @Scion-Kin
"If you can't automate it, it's not worth doing."
MIT – do whatever you want, just don't blame me if you rage-deploy to prod 😄
If you find any bugs or have feature requests, please open an issue on GitHub.
- v1.0 - Initial release with core features
Contributions are welcome! Please fork the repo and submit a pull request.
This script is provided "as-is" without any warranty. Use at your own risk. Always test in a safe environment before deploying to production.