Simple command-line tool that aims to facilitate the continous delivery of PHP apps, particularly Laravel apps. Imagine you want to update your app (in a remote server) when a new commit is pusehd to its repo, but you have no way of ssh'ing into the server or using something like Github Actions. deployer is a cli that can run periodically on the server to check if new code is avaiable, pulling it and executing all the migrations accordingly.
NOTICE:
deployeris a homebrewed solution to solve a very specific problem, there are better ways of doing continous delivery.
Before continuing, make sure you have git, php and composer installed and available.
Clone this repository to a folder in your server (where the to-be-deployed app will run):
git clone --recurse-submodules https://github.com/Dovyski/deployer && cd deployer
Optionally you can make the script globally available to save some typing. First make it executable:
chmod +x deployer.php
Then create an alias for it on your .bash_profile:
echo "alias dpr='/usr/bin/env php $(pwd)/deployer.php'" >> ~/.bash_profile
Source the alias:
source ~/.bash_profile
Finally check if everything is working as intended:
dpr -v
deployer expects two folders are available (and writable) to store files, such as database backups and logs, etc. It is highly recommended to create them.
Somewhere in your system, create the working folders:
mkdir {backups,logs}
Assuming your app is stored in the /home/user/apps/myapp (and that it is a cloned git repo), the command to update the app is:
dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder"
That's it! Your app should be up-to-date and running its latest version.
If you want to periodically update the app, making backups before running any migration, you can add the command above to a crontab:
crontab -e
Add the following:
* * * * * dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder"
In that case, deployer will only run migrations, create backups, etc. if the local version of the app is behind the remote repository. If it is even, nothing will happen locally.
If you are deploying a Laravel app, deployer can be used to init everything for you. In that case, run the following:
dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder" --init="laravel"
If you just want to backup the database of an app that is already running, without updating its code or migrating anything, just run:
dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder" --backup-only
If you are afraid of running anything, you can check what is going to happen by using the --dry-run param:
dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder" --init=laravel --dry-run
In such case deployer will output all commands it intends to run, however no command will actually be executed.
Your help is most welcome regardless of form! Check out the CONTRIBUTING.md file for all ways you can contribute to the project. For example, suggest a new feature, report a problem/bug, submit a pull request, or simply use the project and comment your experience. You are encourage to participate as much as possible, but stay tuned to the code of conduct before making any interaction with other community members.
See the ROADMAP.md file for an idea of how the project should evolve.
This project is licensed under the MIT open-source license and is available for free.
See all changes to this project in the CHANGELOG.md file.
Below is a list of interesting links:
Note: Icons made by Flat Icons from www.flaticon.com.
