Giter Site home page Giter Site logo

vuluchalasarathbabu / apistar-docker-codepipline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wiamsuri/apistar-docker-codepipline

0.0 0.0 0.0 9 KB

This is a guideline of how to set up AWS CodePipeline. Although API Star is used here, the script can be easily converted to other frameworks since the application is dockerized.

License: MIT License

Python 49.67% Shell 27.61% Dockerfile 22.72%

apistar-docker-codepipline's Introduction

API Star Docker CodePipeline

This repository includes code to launch an API Star project to AWS CodeDeploy while using AWS CodeBuild to build the docker image.

Pipeline Overview

GitHub -> AWS CodeBuild -> AWS ElasticContainerRepository -> AWS CodeDeploy

The code committed to GitHub should trigger AWS CodePipeline to bundle the source code and send to AWS CodeBuild. The AWS CodeBuild looks for a file named buildspec.yml at the root level of the repository. This file provides CodeBuild instructions of how to build the code. CodeBuild builds docker image and push the image to AWS ElasticContainerRepository(ECR). In the last section of buildspec.yml, the artifacts gives CodeBuild instruction to save the scripts and send to AWS CodeDeploy for retrieving docker image from ECR. CodeDeploy will receive the zip file containing appspec.yml at root level. CodeDeploy will then use instructions from appspec.yml to get the new docker image up on EC2 instances.

Launch Configuration for new EC2 instances

After choosing the instance type for the launch configuration, you will need to add AmazonEC2RoleforAWSCodeDeploy policy to the IAM role that will be assigned to new EC2 in this launch configuration.

Add the following lines to "User data" section. You may find this in the "Advanced Details" section while setting up the configuration. Change the region name(on the line with curl) of the S3 bucket to have correct installation for your EC2 instances.

#!/bin/bash
sudo yum -y update

curl -O https://aws-codedeploy-ap-southeast-1.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto

sudo yum install -y docker
sudo usermod -a -G docker ec2-user
sudo service docker start
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Permission for AWS CodeBuild to push and pull docker images from ECR(ElasticContainerRepository)

The IAM role assigned to AWS CodeBuild should have the following policies

"Action": [
    "ecr:BatchCheckLayerAvailability",
    "ecr:CompleteLayerUpload",
    "ecr:GetAuthorizationToken",
    "ecr:InitiateLayerUpload",
    "ecr:PutImage",
    "ecr:UploadLayerPart",
    "ecr:GetDownloadUrlForLayer",
    "ecr:BatchGetImage"
]

The full policy JSON will look something like

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ecr:BatchCheckLayerAvailability",
                "ecr:CompleteLayerUpload",
                "ecr:GetAuthorizationToken",
                "ecr:InitiateLayerUpload",
                "ecr:PutImage",
                "ecr:UploadLayerPart",
                "ecr:GetDownloadUrlForLayer",
                "ecr:BatchGetImage"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

While configuring AWS CodeBuild, you will need to specify following environment variables:

AWS_ACCOUNT_ID
AWS_DEFAULT_REGION

apistar-docker-codepipline's People

Contributors

wattcookly avatar wiamsuri avatar

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.