仅使用FTP和PHP即可实现零停机部署

0.2.1 2020-07-26 06:07 UTC

This package is auto-updated.

Last update: 2024-09-26 11:38:55 UTC


README

Latest Stable Version License

此命令行工具与atomic-deploy/server连接,以便将网站原子化部署到托管服务,无需SSH访问。

为什么?现在是2020年,有DigitalOcean、Docker、微服务、Azure、Heroku。为什么我还需要这个?不幸的现实是许多客户仍然停留在古老的共享Web托管上。这为开发人员提供了一种稍微更好的体验,同时无需SSH访问即可工作。

如何?尽管此客户端中集成了FTP组件,例如GitFtpCommandComposerTransferInstalledCommand,但当前推荐的办法是从Git仓库从头开始拉取每个部署。然后atomic-deploy/server将便于运行诸如composer install等操作,尽管无法直接访问服务器。

AtomicDeploy将允许你在服务器上同时拥有多个网站部署,并且可以通过原子rename文件操作在它们之间进行切换,该操作只是切换符号链接。在理想的世界中,这将实现零停机部署。

安全

当然,需要将atomic-deploy/server的安装放置在某种形式的密码屏障之后,因为当涉及到对共享Web托管安装造成破坏时,它基本上与cPanel一样强大。

用法

要查看当前部署列表,请运行

$ adp ls

要推送最新版本

$ adp push

在不同版本之间切换

$ adp use [desired_git_commit]

配置文件

应从您的网站目录中运行adp命令。该目录应包含一个deploy.php文件,该文件存储部署的配置。以下是一个配置文件示例

<?php

return [
    'ftp' => [
        'username' => getenv('FTP_USERNAME'),
        'password' => getenv('FTP_PASSWORD'),
        'host' => getenv('FTP_HOST'),
        'port' => 21,
        'timeout' => 90,
        'passive' => true
    ],

    'server' => [
        'url' => 'http://secure.example.com/deploy/index.php',
        'username' => getenv('DEPLOY_SERVER_USERNAME'),
        'password' => getenv('DEPLOY_SERVER_PASSWORD')
    ],

    'path' => [
        'shared' => 'shared',
        'current' => 'current',
        'next' => 'next'
    ],

    'basePath' => [
        /**
         * The path to the deployments folder, relative to this file.
         */
        'server' => '/path/on/server/to/website_deployments',

        /**
         * The path to the deployments folder, relative to the FTP root
         */
        'ftp' => 'website_deployments',
    ],

    'shared' => [
        '.env',
        'storage/framework',
        'storage/backups',
        'storage/logs',
        'storage/marketplace',
        'storage/proxies',
        'public/content',
        'public/deploy'
    ],

    'copy' => [
        'excludePaths' => [
            'storage',
            'public/vendor'
        ],

        'excludeNames' => [
            'tests',
            'test',
            'docs',
            'doc',
            '.git'
        ]
    ]
];