Package: boss-cli
bossYet another pythonic deployment tool built on top ofparamikoandfabric.Deploy like a boss.Installation$pipinstallboss-cli==1.0.3ConfigurationCheck theconfigurationpage.Custom ScriptsCustom scripts are scripts/commands that could be defined directly in the config file without having to write any line of python in thefabfile.py. They're similar to thenpm scripts, if you're familiar with them.You can define the custom scripts under thescriptsfield in theboss.yml.For instance:# boss.ymlstages:prod:host:your-server.compublic_url:'https://your-server.com'branch:masterscripts:hello:'echo"HelloWorld!"'build:npm run buildlogs:pm2 logsBoss comes out of the box with a taskrunwhich you can use to run these scripts on the remote server like this:$fabprodrun:hello
$fabprodrun:build
$fabprodrun:logsDeployment1. Remote Source DeploymentThis is a generic deployment preset, where the remote host also contains the project source code and the git repository. The deploy task would synchronize the remote with the latest changes of the provided branch from the origin. It then builds the project and restarts the service if needed.This is general and language agnostic so it can be used for deploying any kind of project. You just need to specify the relevantbuildscript to build your project in the remote and if it requires service restart then you'll need to define areloadscript as well.You'll need to set the deployment preset asremote-sourcein your configuration.deployment:
  preset: remote-sourceConfigurationYourboss.ymlfile for remote source deployment would look similar to this:project_name: my-app
project_description: 'My App'
repository_url: 'https://github.com/username/repository'
branch_url: '{repository_url}/tree/{branch}'
user: deploy_user

deployment:
  preset: remote-source
  base_dir: /source/my-app

stages:
  prod:
    host: your-server.com
    public_url: 'https://your-server.com'
    branch: master

scripts:
  install: 'npm install'
  build: 'npm run build'
  start: 'pm2 start dist/myapp.js'
  stop: 'pm2 stop dist/myapp.js'
  reload: 'pm2 reload dist/myapp.js'

notifications:
  slack:
    enabled: true
    endpoint: ${BOSS_SLACK_ENDPOINT}The above configuration is specific to aNode.jsproject environment, but you can also deploy projects built with other languages like PHP, Python, Java etc. All you need to do is change the scriptsinstall,build,reload.Available tasksYou can check the available tasks forremote-sourcepreset withfab --list.➜fab--list

Availablecommands:buildBuildtheapplication.checkCheckthecurrentremotebranchandthelastcommit.deployDeploytoremotesource.prodConfigurestheprodserverenvironment.logsTailthelogs.restartRestarttheservice.runRunacustomscript.statusCheckthestatusoftheservice.stopStoptheservice.syncSyncthechangesonthebranchwiththeremote(origin).DeployNow to deploy the the application to theprodserver that you've configured in thestagesabove. You can do:➜fabproddeployThis would deploy the default branchmasterin this case. You can also provide a specific branch to deploy, as follows:➜fabproddeploy:branch=my-branch2. Web DeploymentThis deployment is useful for deploying the web apps (React, Angular, Vue etc) or static files to the remote server. This preset assumes the static files are served via a web server on the remote host eg: nginx, apache etc. Here, the source code is built locally and only thedistorbuildis uploaded and deployed to the server.The deployment process is zero-downtime, just likecapistrano.You'll need to set the deployment preset aswebin your configuration.deployment:
  preset: webConfigurationYourboss.ymlfile for web deployment would look similar to this:project_name: my-app
project_description: 'My App'
repository_url: 'https://github.com/username/repository'
branch_url: '{repository_url}/tree/{branch}'
user: deploy_user

deployment:
  preset: web
  build_dir: build/           # The local build directory
  base_dir: /app/deployment   # The remote base directory for deployment.

stages:
  prod:
    host: your-server.com
    public_url: 'https://your-server.com'

scripts:
  install: 'npm install'
  build: 'npm run build'

notifications:
  slack:
    enabled: true
    endpoint: ${BOSS_SLACK_ENDPOINT}The above configuration would work for any kind of web projects as long as it generates the build in static files (HTML, CSS, JS, media) that could be served via a web server.You can define two scriptsinstallandbuildin yourboss.yml, to install project dependencies and build the source respectively. For instance: if you've created your application usingcreate-react-app, you can set these tonpm installandnpm run buildas shown in above config.You also have to set the location of the output directory for thebuildscript asdeployment.build_dir. In our case, this would be thebuild/directory.Available TasksYou can check the available tasks for this preset withfab --list.➜fab--list

Availablecommands:buildBuildthecodelocally.buildinfoPrintthebuildinformation.buildsDisplaythebuildhistory.deployZero-Downtimedeploymentfortheweb.infoPrintthebuildinformation.logsTailthelogs.rollbackZero-Downtimedeploymentrollbackfortheweb.runRunacustomscript.setupSetupremotehostfordeployment.prodConfigurestheprodserverenvironment.Remote SetupFor the first time, you can configure the remote host for deployment using thesetuptask.➜fabprodsetupThis will create necessary files and directories on the remote under the providedbase_dirpath. In our case the base directory will be/app/deployment.Once, thesetuptask completes you should see a message like this:Remote is setup and is ready for deployment.

Deployed build will point to /app/deployment/current.
For serving the latest build, please set your web server document root to /app/deployment/current.Now you'll need to set your web server document root on the remote host to thecurrentsymlink created under thebase_dirpath. This symlink will point to the latest build when you deploy your app.Web Server ConfigIf you're using a web server like nginx, you can set the document root like this:# Sample nginx Configuration.
server {
  listen 80;
  listen [::]:80;

  # This is the symlink that points to the build that is deployed.
  root /app/deployment/current;

  index index.html;
  ...
}DeployYou can use thedeploytask to deploy the app to the remote server.Here, first thedeploytask would trigger theinstallandbuildscripts to build the project locally, after which the built directory configured indeployment.build_dirwould be tar-zipped and uploaded to the remote host via SSH.So, to deploy current local source code toprodserver you should do the following:➜fabproddeployIf you're usinggitin your project, you need to make sure you didcheckoutto the branch you want to deploy and is up to date. Like this,# Checkout to the right branch and deploy➜gitcheckoutmaster➜fabproddeploy3. Node.js DeploymentNode.js Project Deployment.
More information, examples and documentation coming soon :).InspirationCapistranoFabricSpecial ThanksSpecial Thanks toShirish Shikhrakarfor thelogo.ContributingAll kinds of contributions are welcome. Read ourcontributing guideto learn about our development process, how to propose PRs, report bugs and suggest improvements.Change LogCheck theCHANGELOGfor full release history.LicenseLicensed underThe MIT License.