{"id":26452118,"url":"https://github.com/derafu/deployer","last_synced_at":"2025-03-18T17:26:22.145Z","repository":{"id":282518921,"uuid":"946207600","full_name":"derafu/deployer","owner":"derafu","description":"PHP Deployer for multiple sites","archived":false,"fork":false,"pushed_at":"2025-03-15T05:46:47.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T06:28:53.750Z","etag":null,"topics":["deployer","deployment","php"],"latest_commit_sha":null,"homepage":"https://derafu.org/deployer/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derafu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-10T19:28:14.000Z","updated_at":"2025-03-15T05:46:50.000Z","dependencies_parsed_at":"2025-03-15T06:29:01.686Z","dependency_job_id":"6e9a25bd-a2b2-4151-a742-92d529f9aede","html_url":"https://github.com/derafu/deployer","commit_stats":null,"previous_names":["derafu/deployer"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derafu%2Fdeployer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derafu%2Fdeployer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derafu%2Fdeployer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derafu%2Fdeployer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derafu","download_url":"https://codeload.github.com/derafu/deployer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244267784,"owners_count":20425896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deployer","deployment","php"],"created_at":"2025-03-18T17:26:21.702Z","updated_at":"2025-03-18T17:26:22.133Z","avatar_url":"https://github.com/derafu.png","language":"PHP","readme":"# Derafu: Deployer - PHP Deployer for multiple sites\n\n![GitHub last commit](https://img.shields.io/github/last-commit/derafu/deployer/main)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/derafu/deployer)\n![GitHub Issues](https://img.shields.io/github/issues-raw/derafu/deployer)\n![Total Downloads](https://poser.pugx.org/derafu/deployer/downloads)\n![Monthly Downloads](https://poser.pugx.org/derafu/deployer/d/monthly)\n\nDerafu Deployer is a PHP deployment tool built on top of [Deployer](https://deployer.org/) that simplifies managing deployments for multiple websites on a single server.\n\n## Features\n\n- Deploy multiple sites from a single configuration.\n- Deploy individual sites or all sites at once.\n- Support for different deployment environments (development, production).\n- Shared files and directories between releases.\n- Writable directories configuration.\n- Asset building support for sites with Node.js/npm.\n- OPcache reset after deployments.\n- Simple and flexible configuration.\n- Support for different Git branches per site.\n\n## Requirements\n\n- PHP 8.3 or higher.\n- SSH access to your servers.\n- Git repositories for your projects.\n\n## Installation\n\n```bash\ncomposer create-project derafu/deployer\n```\n\n**Note**: The tool is designed to be used standalone, not inside other project.\n\n## Configuration\n\n### Sites Configuration\n\nEdit the `sites.php` file to configure your websites. The key of the array is the site/domain name and the value can be:\n\n- A simple string with the repository URL.\n- An array with detailed configuration options.\n\n```php\n\u003c?php\nreturn [\n    // Simple configuration with just the repository URL.\n    'www.example.com' =\u003e 'git@github.com:example/example.git',\n\n    // Extended configuration with options.\n    'www.complex-site.com' =\u003e [\n        'repository' =\u003e 'git@github.com:example/complex-site.git',\n        'branch' =\u003e 'develop',\n        'deploy_path' =\u003e '/var/www/custom/path/complex-site',\n        'shared_files' =\u003e ['.env', 'config/settings.php'],\n        'shared_dirs' =\u003e ['var/uploads', 'var/logs'],\n        'writable_dirs' =\u003e ['var', 'tmp', 'var/cache'],\n        'writable_mode' =\u003e 'chmod',\n        'writable_use_sudo' =\u003e false,\n        'writable_recursive' =\u003e true,\n        'writable_chmod_mode' =\u003e '0775',\n    ],\n];\n```\n\nFor simple configurations you can use:\n\n```shell\n./siteadd.sh www.example.com git@github.com:example/example.git\n```\n\n### Available Configuration Options\n\n| Option              | Description                                  | Default                    |\n|---------------------|----------------------------------------------|----------------------------|\n| repository          | Git repository URL                           | *Required*                 |\n| branch              | Git branch to deploy                         | main                       |\n| deploy_path         | Deployment path on server                    | /var/www/sites/[site-name] |\n| shared_files        | Files to share between releases              | []                         |\n| shared_dirs         | Directories to share between releases        | []                         |\n| writable_dirs       | Directories to make writable                 | ['var', 'tmp']             |\n| writable_mode       | Mode for writable directories                | chmod                      |\n| writable_use_sudo   | Whether to use sudo for writable directories | false                      |\n| writable_recursive  | Apply writable permissions recursively       | true                       |\n| writable_chmod_mode | Chmod mode for writable directories          | 0777                       |\n\n### Server Configuration\n\nThe server configuration is defined in `deploy.php`. By default, a development environment on localhost and an optional production environment are configured:\n\n```php\n// Default development environment.\nhost('localhost')\n    -\u003esetRemoteUser('admin')\n    -\u003esetPort(2222)\n    -\u003esetLabels(['stage' =\u003e 'dev']);\n\n// Production environment (only if DEPLOYER_HOST is set).\nif (getenv('DEPLOYER_HOST')) {\n    host(getenv('DEPLOYER_HOST'))\n        -\u003esetRemoteUser(getenv('DEPLOYER_USER') ?: 'admin')\n        -\u003esetPort(getenv('DEPLOYER_PORT') ?: 2222)\n        -\u003esetLabels(['stage' =\u003e 'prod']);\n    set('default_selector', 'stage=prod');\n}\n```\n\nYou can modify these settings or add additional environments as needed.\n\n## Usage\n\n### List Available Sites\n\nTo see the list of configured sites and usage information:\n\n```bash\nvendor/bin/dep derafu:sites:list\n```\n\n### Deploy a Single Site\n\n#### Development Environment (localhost)\n\n```bash\nvendor/bin/dep derafu:deploy:single --site=www.example.com\n```\n\n#### Production Environment\n\n```bash\nDEPLOYER_HOST=hosting.example.com vendor/bin/dep derafu:deploy:single --site=www.example.com\n```\n\nYou can also specify the SSH user and port:\n\n```bash\nDEPLOYER_HOST=hosting.example.com DEPLOYER_USER=deployuser DEPLOYER_PORT=22 vendor/bin/dep derafu:deploy:single --site=www.example.com\n```\n\n### Deploy All Sites\n\n#### Development Environment (localhost)\n\n```bash\nvendor/bin/dep derafu:deploy:all\n```\n\n#### Production Environment\n\n```bash\nDEPLOYER_HOST=hosting.example.com vendor/bin/dep derafu:deploy:all\n```\n\n### Unlock a Deployment\n\nIf a deployment gets stuck or locked, you can unlock it:\n\n```bash\nDEPLOYER_HOST=hosting.example.com vendor/bin/dep derafu:deploy:single --site=www.example.com --unlock\n```\n\n## Deployment Process\n\nFor each site, the deployment process performs the following steps:\n\n1. **Check Remote**: Verifies SSH connection and deployment path.\n2. **Prepare**: Creates required directories if they don't exist.\n3. **Update Code**: Fetches code from the Git repository.\n4. **Shared Files/Dirs**: Links shared files and directories.\n5. **Writable Dirs**: Makes specified directories writable.\n6. **Vendors**: Installs PHP dependencies with Composer.\n7. **Assets**: Builds frontend assets if package.json exists (`npm install \u0026\u0026 npm run build`).\n8. **Symlink**: Creates a symlink to the new release.\n9. **Unlock**: Removes the deployment lock.\n10. **Cleanup**: Removes old releases (keeps 5 by default).\n11. **OPcache Reset**: Resets the OPcache.\n\n## Customization\n\nYou can extend the deployer recipe by editing the `multisites.php` file to add custom tasks or modify existing ones.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderafu%2Fdeployer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderafu%2Fdeployer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderafu%2Fdeployer/lists"}