@danmasta/deploy

Deployment tool for aws and docker

Usage no npm install needed!

<script type="module">
  import danmastaDeploy from 'https://cdn.skypack.dev/@danmasta/deploy';
</script>

README

Deploy

Easy deployment to AWS ECR repositories and Elastic Beanstalk environments using docker and aws cli

Features:

  • Easy to use
  • Build and tag docker images
  • Push docker images to private ECR registries
  • Deploy applications to elastic beanstalk environments
  • Interactive cmd line utility
  • Non-interactive mode for easy deployments from CI tools
  • Supports deployment to multiple AWS regions

About

We needed a better way to package and deploy apps. This package aims to make deployments to multiple elastic beanstalk apps and environments really simple. It can be used as a non-interactive cmd line utility, required and used programatically, or as an interactive cmd line prompt.

Usage

Install globally with npm

npm install -g @danmasta/deploy

Run the deploy script

deploy

For more usage info check out the examples

Options

Options can be passed via cmd line arguments, as an object if you require the package programatically, or stored with your other configuration if using a config package.

Name Alias Type Desription
name n string Docker image name
version v string What version to tag the docker image
ecrUri u string ECR repository uri to push docker image to
region r string|array AWS region(s) to deploy to
eb string|boolean If true will trigger the elastic beanstalk deploy step
ebApp a string Elastic Beanstalk application name
ebEnv e string Elastic Beanstalk environment name
ebBucket b string AWS s3 bucket name to push application zip to
dockerrun d string Where is your projects dockerrun file located
outputDir o string Where to save application zip before uploading
silent s string|boolean If false no output will be logged
interactive i string|boolean If true will trigger interactive mode
regionList string|array List of AWS region(s) to show as selection options in interactive mode
help h boolean Show help menu in console

It's really simple to store default deploy opts in config and just run deploy

Setup

Check out the wiki for some basic instructions to help get you started with docker and aws. These may not be exhaustive, but should be enough to get you headed in the right direction

Examples

Use config to set defaults

// ./config/default.js
module.exports = {
    deploy: {
        name: 'my-app',
        version: null,
        region: 'us-east-1',
        eb: true,
        ebApp: 'my-app',
        ebEnv: 'my-app-prod',
        ecrUri: '<ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com',
        ebBucket: 'elasticbeanstalk-<REGION>-<ACCOUNT_ID>',
        dockerrun: './Dockerrun.aws.json',
        outputDir: './dist/deploy',
        interactive: true,
        regionList: [
            'us-west-2',
            'us-east-1',
            'eu-west-1',
            'ap-northeast-1'
        ]
    }
};
// ./config/qa1.js
module.exports = {
    deploy: {
        ebEnv: 'my-app-qa1',
        regionList: [
            'us-east-1',
        ]
    }
};

Multiple Configs / Environments

Since this package uses the env and config pacakges, you can easily switch config values with cmd args. So if you have a config structure like this

./config/default.js
./config/production.js
./config/staging.js
./config/qa1.js
./config/qa2.js

You can then load deploy values for a specific environment by just running

deploy --env production --config qa1

Use non-interactive mode to deploy from your CI tool

deploy --eb -i false -v 2.1.5 -n app -a app -e app-prod -u ... -b ... -r us-east-1 -r ap-south-1

Require the package and run using gulp

const gulp = require('gulp');
const deploy = require('@danmasta/deploy');
const pkg = require('./package');

gulp.task('deploy', gulp.series('tests'), () => {

    return deploy({
        interactive: false,
        name: 'app',
        version: pkg.version,
        region: ['us-east-1'],
        eb: true,
        ebApp: 'app',
        ebEnv: 'app-prod',
        ecrUri: '...',
        ebBucket: '...'
    });

});

Dockerrun Examples

Check out the wiki for some examples on to configure your dockerrun files. I like to use the AWS multi-docker AMI for my environments, and then just configure one or more containers for each app

Contact

If you have any questions feel free to get in touch