Giter Site home page Giter Site logo

dployer's Introduction

dployer

A simple script to deploy PHP applications in a few minutes to ElasticBeanstalk.



Installation

Composer

composer global require "leroy-merlin-br/dployer=*@dev"

Global config for dployer

AWS config

You have 2 options to configure AWS:

  • Environment Variables
  • JSON configuration file

Environment Variables

You must fill the following environment variables.

  • DPLOYER_PROFILE : Your profile's name in AWS.
  • DPLOYER_REGION : Your region you want to deploy something.
  • DPLOYER_AWS_KEY : Your secret AWS key.
  • DPLOYER_AWS_SECRET : Your secret AWS SECRET.

JSON Configuration File

  • Create the following configuration file: ~/.aws/config.json
{
    "includes": ["_aws"],
    "services": {
        "default_settings": {
            "params": {
                "profile": "my_profile",
                "region": "sa-east-1",
                "key": "YOURSUPERKEY",
                "secret": "YoUrSuPeRsEcReT"
            }
        }
    }
}

AWS Bucket

Add the following line in the end of the ~/.bashrc file:

export DPLOYER_BUCKET=your-bucket-identifier-0-12345678

Usage

Inside the folder that you want to deploy, just run:

dployer deploy ApplicationName elasticbeanstalked-environment

Options

You can use the following options:

  • -c (--config): Use a custom configuration file different from .dployer
  • -i (--interactive): Asks before run each command in configuration file
  • -v (--verbose): Display command outputs
  • -f (--force): Continue with deploy process even if a script exits with error

Project configuration

In order to optimize the deploy of your project, you can create a configuration file to keep application and environment variables. In addition, you gain some extra features, like: events to run the scripts that you want and options to copy extra files and delete some files before zip them.

Just create a .dployer file in project root dir.

Note: Once you have .dployer file with application and environment variables defined, you can just run the command as following:

dployer deploy

Sample .dployer

{
    "application": "ApplicationName",
    "environment": "my-environment",
    "scripts": {
        "init": "composer dumpautoload",
        "before-pack": [
            "gulp build --production"
        ],
        "before-deploy": [
            "echo 'Deploying new version'",
            "echo 'Another important command to run before deploy'"
        ],
        "finish": [
            "gulp clean",
            "echo 'Nicely done'"
        ]
    },
    "copy-paths": [
        "vendor",
        "public/assets"
    ],
    "exclude-paths": [
        ".git",
        "vendor/**/*.git"
    ]
}

Events

Dployer triggers 4 events in deploy flow:

  • init: Runs after initial validations and before any command of deploy
  • before-pack: Runs before create the zip file
  • before-deploy: Runs before create ElasticBeanstalk version and upload zip
  • finish: Runs after upload new version

copy-paths

The dployer just clone your current git branch inside a temp folder, then it creates a zip file. But sometimes, you want to deploy some files which are ignored by git (inside .gitignore file).

In this case, you can put these files/folders in copy-paths key in configuration file as demonstrated in sample section.

.dployer

(...)
"copy-paths": [
    "vendor",
    "public/assets/"
]
(...)

exclude-paths

In another case, sometimes you want to exclude some files/folders too.

.dployer

(...)
"exclude-paths": [
    ".git",
    "vendor/**/*.git"
]
(...)

dployer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dployer's Issues

Create new deploy tag version 1.1

@Zizaco and @GuilhermeGuitte:

I think that these recent pull requests (#6, #9 and #10) resolves our actual problems.I think we can create a new version of dployer bin and tag it with version 1.1:

Main changelog:

  • Added configuration file
  • Moved application and environment arguments to config file
  • Create events
  • Configurable scripts by event
  • Interactive mode
  • More Verbosity

What do you guys think?

  • Rebuild dployer bin
  • Update README.md file
  • Tag 1.1 version

Configuration file on root path of the project

Create a configuration file in the project base path to configure deploy process. The file should follow this structure:

{
    "application": "MyAwsomeApplication",
    "environment": "my-staging-env",
    "scripts": {
        "init": "composer dumpautoload",
        "another-random-event": [
            "echo 'Keep going...'", 
            "echo 'Almost there!'"
        ],
        "finish": "echo 'Nicely done! =)'"
    },
    "exclude-path": [
        "path/to/non-deployed-folder",
        "i-dont-want-to-deploy-this-file.log"
    ]
}

Note: even with application and environment keys in the configuration file, the deploy command should keep the possibility to pass this arguments as command parameters.

To do:

  • Create sample configuration file to test.
  • Create class to read config keys.
  • Remove required option from app and environment arguments in deploy command
  • Exclude paths in the exclude-path key before ZIP them.
  • Add support to dispatch events.
  • Create a class to listen the events and execute commands.
  • Apply key events in deploy process, i.e, init, finish, before-pack, after-version-deploy...

Create -V (--verbose) argument to deploy command

If deploy command is executed with --verbose argument, the command should display outputs from scripts that are configured in .dployer file

Note: Save -v (in lowercase) argument to display version in the future

Fix --interactive option

Even if you don't use this parameter when you run deploy command, dployer asks for confirmation before run every script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.