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.
-
Create a new repo by following the Creating a repository from a template guide.
-
Clone the repo
git clone github.com/your_username/repo
-
Copy the files and
Dockerfile
needed for your container to the cloned repo.
-
Clone this repo
git clone github.com/replicant0wnz/ecr-template
-
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
-
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 therepository
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" } }
-
Setup your AWS credentials via the
AWS_ACCESS_KEY_ID
andAWS_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}'`
-
Execute
make all
-
Setup your AWS credntials under Settings -> Secrets -> Actions. Refer to Encrypted secrets
Example:
-
Update the following section of
.github/actions/release
with the version tag you'd like to use. iev1.*
or1.*
orrelease-*
etcon: push: tags: - 1.*
-
Tag the release to deploy. Example:
git tag 1.1.2 ; git push origin --tags