Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save felicianotech/56ad8f63156e233e6a16df50fe6d4791 to your computer and use it in GitHub Desktop.
Save felicianotech/56ad8f63156e233e6a16df50fe6d4791 to your computer and use it in GitHub Desktop.
Using AWS ECR with CircleCI 2.0 (docker executor)
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
steps:
- checkout
- setup_remote_docker
- run:
name: install aws
command: |
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
- run:
name: "Log in to AWS ECR"
command: eval $(aws ecr get-login)
- run:
name: "Build & Push Docker Image"
command: |
docker build -t $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/my-app:latest -t $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/my-app:$CIRCLE_SHA1 .
docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/my-app:$CIRCLE_SHA1
# In this example, the following environment variables would need to be set in CircleCI's UI:
#
# - AWS_ACCOUNT_ID
# - AWS_ACCESS_KEY_ID
# - AWS_SECRET_ACCESS_KEY
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment