Deployment

We recommend to use Packer and this AMI as a base image to build your own AMIs right from your CI/CD pipeline. Use the provisioners section in your Packer script in order to copy your configuration files to the conf folder and your source code to the src folder. You might also want to run any additional scripts or commands that don’t require the project to be running, for example, package managers install process (npm, composer, pip, etc…​).

Proposed Packer configuration:

{
    "builders": [
        {
            "type": "amazon-ebs",
            "region": "us-east-1",
            "source_ami_filter": {
                "filters": {
                    "virtualization-type": "hvm",
                    "name": "Develatio - Django - Ruby 2 v0.1.0*",
                    "root-device-type": "ebs"
                },
                "owners": ["679593333241"],
                "most_recent": true
            },
            "snapshot_tags": {
                "Name": "My Project build with Develatio's Ruby on Rails AMI"
            },
            "instance_type": "t3.xlarge",
            "ssh_username": "admin",
            "ssh_interface": "public_ip",
            "ami_name": "My Project build with Develatio's Ruby on Rails AMI",
            "force_delete_snapshot": true,
            "force_deregister": true,
            "shutdown_behavior": "terminate"
        }
    ],

    "provisioners": [
        {
            "destination": "/var/www/webapp/",
            "source": "./files.zip",
            "type": "file"
        },
        {
            "type": "shell",
            "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} bash -l {{ .Path }}",
            "inline": [
                "cd /var/www/webapp",
                "unzip -q files.zip",
                "rm files.zip",
                "cd /var/www/webapp/src",
                "bundle install"
            ]
        }
    ]
}