Skip to content
/ ecr-template Public template

Template for deploying Docker containers to Amazon Elastic Container Registry

License

Notifications You must be signed in to change notification settings

replicant0wnz/ecr-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecr-template

GitHub Actions Latest commit LICENSE

Makefile

Template for deploying Docker containers to Amazon Elastic Container Registry (ECR). It allows you to either deploy locally via the command line or by Github Actions.

Usage

Setup

New repo

  1. Create a new repo by following the Creating a repository from a template guide.

  2. Clone the repo

    git clone github.com/your_username/repo
  3. Copy the files and Dockerfile needed for your container to the cloned repo.

Existing repo

  1. Clone this repo

    git clone github.com/replicant0wnz/ecr-template
  2. Copy the Makefile, makefile.json, and the .github/workflows/release.yml files to your repo directory.

    cp Makefile makefile.json .github/workflows/release.yml /path/to/your/repo

Modify the makefile.json file

  1. aws:account_id : Your AWS account ID
    aws:ecr:region : Region your registry is located
    aws:ecr:uri : URI for your registry
    docker:image_name : Name for the Docker image (Must match the repository name you created in ECR)

    Example:

    {
        "aws": {
            "account_id" : "123456789012",
            "ecr" : {
                "region" : "us-east-1",
                "uri" : "public.ecr.aws/your_ecr"
            }
        },
        "docker": {
            "image_name" : "alpine"
        }
    }
    

Deploying to ECR

Via the command line

  1. Setup your AWS credentials via the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

    Example:

    export AWS_ACCESS_KEY_ID=`grep aws_access_key_id ~/.aws/credentials | awk '{print $3}'`
    export AWS_SECRET_ACCESS_KEY=`grep aws_secret_access_key ~/.aws/credentials | awk '{print $3}'`
  2. Execute make all

Github Actions via a tag

  1. Setup your AWS credntials under Settings -> Secrets -> Actions. Refer to Encrypted secrets

    Example:

    Example

  2. Update the following section of .github/actions/release with the version tag you'd like to use. ie v1.* or 1.* or release-* etc

     on: 
       push:
         tags:
           - 1.*
  3. Tag the release to deploy. Example:

    git tag 1.1.2 ; git push origin --tags

About

Template for deploying Docker containers to Amazon Elastic Container Registry

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published