This script is designed for deploying Docker images to remote servers over SSH. The script checks necessary dependencies, builds Docker images, and deploys it on the server.
- Docker Engine installed both on the local system and the server
- Remote server SSH access from the local system
- Docker images should be present on the Docker Hub
- Web project where will be deployed
.
├── deploy.example.conf
├── deploy.sh
└── function
├── docker_utils.sh
├── ssh_utils.sh
└── utils.sh
deploy.example.conf: Configuration file for Docker and SSH settingsdeploy.sh: Deployment script that runs the deployment processfunction/: Contains utility bash scriptsdocker_utils.sh: Contains Docker related utility functionsssh_utils.sh: Contains SSH related utility functionsutils.sh: Contains other utility functions
Before running the script, you should fill deploy.example.conf with proper values:
- Replace
<placeholders>indeploy.example.confwith actual values.
Then, rename the file as per your environment:
- Rename
deploy.example.conftodeploy.conf.
After setup and configuration, run the script from your terminal:
$ chmod +x deploy.sh # provides executable permissions
$ ./deploy.sh # executes the scriptThe script will handle the following steps:
- Login to Docker Hub
- Check Docker installation
- Build and push Docker images
- Setup SSH to establish a communication between the local system and the server
- Deploy Docker images on the server
Ensure that the local system has the authorization to deploy Docker images on the remote server.
The command can be terminated anytime by pressing ctrl + c.