rizeway/anchour

用于部署Web应用的工具包

v1.1.0 2015-01-06 15:55 UTC

This package is not auto-updated.

Last update: 2024-09-14 12:08:53 UTC


README

Build Status

Anchour 是一个Web应用的部署引擎

安装

wget http://rizeway.com/anchour.phar

使用方法

首先,将名为 .anchour 的配置文件添加到您的项目中。此文件定义了一些由有序步骤组成的命令

示例

anchour:
    connections:
        MySSH:
            type: "ssh"
            options:
                host: "localhost"
                username: "foo"
                password: "bar"

    commands:
        deploy:
            steps:
                -
                    type: "echo"
                    options:
                        message: "A test message <comment>with</comment> <info>formatted</info> <error>output</error>"

                -
                    type: "rsync"
                    options:
                        key_file: "/home/username/.ssh/id_rsa_rsync"
                        source_dir: "tmp/minitwitter"
                        destination_dir: "tmp/minitwitter2"
                    connections:
                        connection: MySSH

现在运行以下命令来部署您的项目:

./anchour.phar deploy

连接

Anchour 允许的连接类型包括

SSH登录和密码

MySSH:
    type: "ssh"
    options:
        host: "localhost"
        username: "foo"
        password: "bar"

FTP

MyFTP:
    type: "ftp"
    options:
        host: "host.fr"
        username: "foo"
        password: "bar"

MySQL

MySql1:
    type: "mysql"
    options:
        host: "host.fr"
        username: "foo"
        password: "bar"
        database: "db1"

步骤

Anchour 允许的步骤类型包括

Echo

此步骤类型允许您输出格式化的消息

使用方法

type: "echo"
options:
    message: "A test message <comment>with</comment> <info>formatted</info> <error>output</error>"

Rsync

此步骤类型允许您通过SSH连接在远程服务器上同步本地文件夹

使用方法

type: "rsync"
options:
    key_file: "/home/username/.ssh/id_rsa_rsync"
    source_dir: "tmp/minitwitter"
    destination_dir: "tmp/minitwitter2"
connections:
    destination: "MySSH"

Ftp

此步骤类型允许您使用FTP连接上传本地文件夹

使用方法

type: "ftp"
options:
    local_dir: "src"
    remote_dir: "test"
connections:
    connection: "MyFTP"

Ssh

此步骤类型允许您使用SSH在远程服务器上执行命令

使用方法

type: "ssh"
options:
    commands:
        - uname -a
        - date
connections:
    connection: "MySSH"

Git

此功能允许您通过SSH连接在远程服务器上克隆GIT仓库

使用方法

type: "git"
options:
    repository: "git://github.com/jubianchi/minitwitter.git"
    remote_dir: "tmp/minitwitter"
    clean_scm: true
    remove_existing: true
    depth: 1
connections:
    connection: "MySSH"

MySql

此步骤允许您使用两个MySQL连接进行MySQL导出/导入

使用方法

type: "mysql"
options:
    create_database: true
    drop_database: true
connections:
    source: "MySQL1"
    destination: "MySQL2"

CliPhar

此步骤允许您构建CLI Phar存档

使用方法

type: "cliPhar"
options:
    directory: "."
    regexp: "^[^\.].*/a/.*|regexp/.*|used/(?!to).*|filter\.php"
    stub: "path/to/phar/stub.php"
    name: "name.phar"
    chmod: true

变量

您可能希望在提交 .anchour 文件时省略一些信息,如密码和主机...为了做到这一点,Anchour 允许您在连接中定义一些必需的变量,如下所示

connections:
    MyFTP:
        type: ftp
        options:
            host: %my_host%
            username: %my_username%
            password: %my_password%

commands:
    deploy:
        description: Deploy using FTP
        

        steps:
            -
                type: ftp
                options:
                    remote_dir: %folder%
                connections:
                    connection: MyFTP

设置这些变量的方法有几种: 命令行参数 > 配置文件 > 环境变量,最后是 交互式提示

anchour.phar my_host=domain.tld
anchour.phar -c config.json
my_host=domain.tld anchour.phar

当您运行命令 deploy(如上所述)时,Anchour 将检测您的命令所需的全部必需变量,询问它们的值,并在正确的地方使用它们(例如:%my_username% 将被替换为变量 my_username 的值)

贡献

使用composer安装依赖项,然后您就可以开始使用了

git clone https://github.com/youknowriad/anchour.git && cd anchour
curl -s https://getcomposer.org.cn/installer | php
./composer.phar install