A powerful, cross-platform CLI tool that automates AWS ECR repository creation and Docker image deployment. Built with Go for speed, reliability, and ease of use across development teams.
- π Automated ECR repository creation - Creates repositories if they don't exist
- π³ Docker integration - Handles authentication, building, and pushing
- π€ AWS profile support - Use multiple AWS profiles seamlessly
- π Cross-platform - Works on Linux, Windows, and macOS
- π·οΈ Flexible tagging - Custom tags or default to 'latest'
- π» Interactive mode - User-friendly prompts when needed
- π¦ Easy distribution - Pre-built binaries and packages
- β‘ Fast deployment - Optimized workflow for quick deployments
# Linux/macOS
curl -sSL https://raw.githubusercontent.com/Deepak-coder80/ecr-deploy/main/install.sh | bash
# Windows (PowerShell as Administrator)
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Deepak-coder80/ecr-deploy/main/install.ps1" | Invoke-Expressionwget https://github.com/Deepak-coder80/ecr-deploy/releases/latest/download/ecr-deploy-1.0.0-linux-amd64.deb
sudo dpkg -i ecr-deploy-1.0.0-linux-amd64.debwget https://github.com/Deepak-coder80/ecr-deploy/releases/latest/download/ecr-deploy-1.0.0-linux-amd64.tar.gz
tar -xzf ecr-deploy-1.0.0-linux-amd64.tar.gz
sudo cp usr/local/bin/ecr-deploy /usr/local/bin/- Download ecr-deploy-1.0.0-windows-amd64.zip
- Extract the zip file
- Run
install.batas Administrator - Restart your terminal
# Intel Macs
wget https://github.com/Deepak-coder80/ecr-deploy/releases/latest/download/ecr-deploy-1.0.0-darwin-amd64.tar.gz
tar -xzf ecr-deploy-1.0.0-darwin-amd64.tar.gz
cd ecr-deploy-1.0.0-darwin-amd64 && ./install.sh
# Apple Silicon Macs
wget https://github.com/Deepak-coder80/ecr-deploy/releases/latest/download/ecr-deploy-1.0.0-darwin-arm64.tar.gz
tar -xzf ecr-deploy-1.0.0-darwin-arm64.tar.gz
cd ecr-deploy-1.0.0-darwin-arm64 && ./install.sh# Simple deployment to ECR
ecr-deploy --repo my-web-app
# With specific AWS profile
ecr-deploy --repo my-api --profile production
# Custom region and tag
ecr-deploy --repo my-service --region eu-west-1 --tag v2.1.0
# From specific directory
ecr-deploy --repo backend-service --path ./services/backend/
# Interactive mode (prompts for repository name)
ecr-deployUsage:
ecr-deploy [flags]
Flags:
-h, --help help for ecr-deploy
-l, --list-profiles List available AWS profiles
-p, --path string Path to Dockerfile directory (default: current directory)
--profile string AWS profile to use (default: default profile)
-r, --region string AWS region (default: "us-east-1")
-n, --repo string ECR repository name
-t, --tag string Docker image tag (default: "latest")
Commands:
examples Show usage examples
version Print version informationecr-deploy --list-profiles# Development
ecr-deploy --repo my-app --profile dev --region us-west-2 --tag dev-$(git rev-parse --short HEAD)
# Staging
ecr-deploy --repo my-app --profile staging --region us-east-1 --tag staging-v1.2.3
# Production
ecr-deploy --repo my-app --profile prod --region us-east-1 --tag v1.2.3- AWS CLI - Configured with appropriate credentials
- Docker - Running and accessible
- Git (optional) - For version tagging
Your AWS user/role needs the following ECR permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:CreateRepository",
"ecr:DescribeRepositories"
],
"Resource": "*"
}
]
}# Configure default profile
aws configure
# Configure additional profiles
aws configure --profile production
aws configure --profile stagingname: Deploy to ECR
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Install ECR Deploy Tool
run: |
wget https://github.com/Deepak-coder80/ecr-deploy/releases/latest/download/ecr-deploy-1.0.0-linux-amd64.tar.gz
tar -xzf ecr-deploy-1.0.0-linux-amd64.tar.gz
sudo cp usr/local/bin/ecr-deploy /usr/local/bin/
- name: Deploy to ECR
run: |
IMAGE_URI=$(ecr-deploy --repo ${{ github.event.repository.name }} --tag ${{ github.sha }})
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV
- name: Update ECS service
run: |
# Use $IMAGE_URI in your deployment scripts
echo "Deploying $IMAGE_URI to ECS..."pipeline {
agent any
environment {
AWS_REGION = 'us-east-1'
ECR_REPO = "${env.JOB_NAME}"
}
stages {
stage('Build and Deploy to ECR') {
steps {
script {
// Install ECR Deploy Tool
sh '''
wget -q https://github.com/Deepak-coder80/ecr-deploy/releases/latest/download/ecr-deploy-1.0.0-linux-amd64.tar.gz
tar -xzf ecr-deploy-1.0.0-linux-amd64.tar.gz
sudo cp usr/local/bin/ecr-deploy /usr/local/bin/ || cp usr/local/bin/ecr-deploy ./
'''
// Deploy to ECR
def imageUri = sh(
script: "./ecr-deploy --repo ${ECR_REPO} --region ${AWS_REGION} --tag ${env.BUILD_NUMBER}",
returnStdout: true
).trim()
env.IMAGE_URI = imageUri.split('\n').last().split(': ')[1]
echo "Deployed image: ${env.IMAGE_URI}"
}
}
}
}
}deploy_to_ecr:
stage: deploy
image: docker:latest
services:
- docker:dind
before_script:
- apk add --no-cache curl
- curl -sSL https://raw.githubusercontent.com/Deepak-coder80/ecr-deploy/main/install.sh | sh
script:
- ecr-deploy --repo $CI_PROJECT_NAME --tag $CI_COMMIT_SHA
only:
- main- Go 1.21 or higher
- Make (optional, for using Makefile)
- Git
# Clone the repository
git clone https://github.com/Deepak-coder80/ecr-deploy.git
cd ecr-deploy
# Option 1: Use automated setup
./quick-setup.sh
# Option 2: Manual setup
go mod download
go mod tidy
make build# Run in development mode
make dev
# Build for current platform
make build
# Build for all platforms
make build-all
# Create distribution packages
make dist
# Run tests
make test
# Format and lint code
make lint
# Clean build artifacts
make clean
# Install locally for testing
make installecr-deploy/
βββ main.go # Main application
βββ go.mod # Go module dependencies
βββ go.sum # Dependency lock file
βββ Makefile # Build automation
βββ README.md # This file
βββ LICENSE # License file
βββ .gitignore # Git ignore rules
βββ build/ # Built binaries (gitignored)
βββ dist/ # Distribution packages (gitignored)
βββ docs/ # Additional documentation
βββ CONTRIBUTING.md # Contribution guidelines
βββ DEPLOYMENT.md # Deployment guide
- π Repository Check - Verifies if ECR repository exists
- π¦ Repository Creation - Creates repository if it doesn't exist
- π Authentication - Handles Docker login to ECR
- ποΈ Image Building - Builds Docker image with proper ECR URI
- π€ Image Pushing - Pushes image to ECR with specified tag
- π Output - Returns complete image URI for deployment use
π Starting ECR deployment for repository: my-web-app
π Region: us-east-1
π€ AWS Profile: production
π Dockerfile path: .
π·οΈ Tag: v1.2.0
βββββββββββββββββββββββββββββββββββββββββββββββββββ
π§ Initializing AWS session (Region: us-east-1, Profile: production)
β
AWS Authentication successful! Account: 123456789012
π Checking if ECR repository 'my-web-app' exists...
π¦ Creating ECR repository 'my-web-app'...
β
Repository 'my-web-app' created successfully!
π Authenticating Docker with ECR...
π Executing: bash -c aws ecr get-login-password --region us-east-1 --profile production | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com
ποΈ Building Docker image: 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-web-app:v1.2.0
π Executing: docker build -t 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-web-app:v1.2.0 .
π€ Pushing image to ECR: 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-web-app:v1.2.0
π Executing: docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-web-app:v1.2.0
βββββββββββββββββββββββββββββββββββββββββββββββββββ
π Deployment completed successfully!
β±οΈ Total time: 45s
π Image URI: 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-web-app:v1.2.0
βββββββββββββββββββββββββββββββββββββββββββββββββββ
# Check AWS configuration
aws configure list
aws sts get-caller-identity
# Verify profile exists
ecr-deploy --list-profiles
# Test with specific profile
aws sts get-caller-identity --profile your-profile-name# Check Docker status
docker info
# Start Docker (Linux)
sudo systemctl start docker
# Check Docker permissions (Linux)
sudo usermod -aG docker $USER
# Log out and back in# Clean and rebuild
make clean
go mod tidy
make build
# Update dependencies
go get -u ./...
go mod tidy# Linux: Add user to docker group
sudo usermod -aG docker $USER
# AWS: Check ECR permissions
aws ecr describe-repositories --region us-east-1# Show help
ecr-deploy --help
# Show examples
ecr-deploy examples
# Check version
ecr-deploy versionWe welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests:
make test - Submit a pull request
- Follow Go best practices
- Add tests for new features
- Update documentation
- Use conventional commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS SDK for Go - AWS integration
- Cobra - CLI framework
- Viper - Configuration management
- π Documentation: Wiki
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: deepakcoder80@gmail.com
- Configuration file support (
.ecr-deploy.yaml) - Multi-tag deployment in single command
- Batch repository operations
- ECS/EKS integration helpers
- Docker Compose support
- Vulnerability scanning integration
Made with β€οΈ by the DevOps Team
β Star this repo if it helped you! β