releaz/deployer

Yii2 Deployer (Based on Deployer)

1.2.6 2017-06-26 13:39 UTC

This package is not auto-updated.

Last update: 2025-01-19 04:20:08 UTC


README

Build status: Build Status

Build status Deployer: Build Status

Docs: https://releaznl.github.io/releaz-deployer

Packagist: https://packagist.org/packages/releaz/deployer

This tool is created for easy Yii2 deployment with the help of Deployer. In this tool it's easy to configure deployment variables and share them between your colleagues.

Deployment:

Deploying is done with the help of Deployer. To use this dependency, please require the following in your composer.json file.

  • composer require releaz/deployer

Afterwards initialize Deployer by calling vendor/bin/dep init and choose the 'Releaz' template. Doing so will generate an example config and the required Deployer deploy.php file. Please look below for more information on how to configure this file. Create the Yii2 configutation file by duplicating the generated .example config file in the common folder. By default the deploy.php file looks for deploy-config.yml

The deploy.php file can be edited in the same manner as Deployer. Please visit the Deployer documentation for more help.

Explanation:

# General information:
general:
  ssh_repo_url: 'git@github.com:johankladder/yii2-app-advanced.git'   # The repository your project is stored

# Staging servers:
server:
  # The production server
  production:
    host: 'applicationname.com'                       # Deployment server hostname/ip
    stage: 'production'                               # Stage name; can be used by 'dep deploy-yii [stage]
    branch: 'master'                                  # The branch that should be used to deploy
    deploy_path: '/var/www/applicationname.com'       # The deploy location
    ssh_user: 'username'                              # The SSH username, that has access to the remote server

  # The development server
  development:
    host: 'dev.applicationname.com'                   # Deployment server hostname/ip
    stage: 'development'                              # Stage name; can be used by 'dep deploy-yii [stage]
    branch: 'develop'                                 # The branch that should be used to deploy
    deploy_path: '/var/www/dev.applicationname.com'   # The deploy location
    ssh_user: 'username'                              # The SSH username, that has access to the remote server

  # A custom deployment server:
  custom:
    host: 'localhost'                                 # Deployment server hostname/ip
    stage: 'test'                                     # Stage name; can be used by 'dep deploy-yii [stage]
    branch: 'develop'                                 # The branch that should be used to deploy
    deploy_path: '/var/www/test.local'                # The deploy location
    ssh_user: 'johankladder'                          # The SSH username, that has access to the remote server
    settings:
      yii:
        init: 'Development'                           # Environment that can be used. See `php init` for possibilities
        overwrite: 'All'                              # Overwrite all the generated files during init | Can also be None
      files:
        upload-files:
          - 'common/config/afile.yml'                 # A file that needs the be send to the remote server
        show:
          - 'common/config/afile.yml'                 # A file that needs to be outputted when deploying
      migrate:
        rbac: true                                    # Execute RBAC migrations
        db: true                                      # Execute `yii migrate`
      sync:
        uploads:
          source: 'shared/uploads/'                   # Base of the sync folder
          dest: 'shared/uploads'                      # 'To' pathname from base deployment path
          create_if_not_exists: true                  # Create the 'To' path if not exist
    shared:
      - 'common/config/config.yaml'

In the server section you can add different amount of stages. The keys that are given, are not used by Deployer. Explanation:

Passwords

The module uses forward-agent to grant your user access to the remote server without the need of a password. Follow the following steps to ensure no password is needed:

  • Try ssh-add -L to see if your public key is added to the agent. If not run: ssh-add
  • Copy your public key to the remote server's known-hosts with ssh-copy-id remoteusername@remotehost
  • Try ssh remoteuser@remotehost. The server should no longer ask for a password as it is now provided by the agent.

Remote server access repository

To give the deployment server access to your private/public repository on Github, please provide the server's public SSH key as a deployment key in your repository settings.