Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Build and push Docker image to ECR #328

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

orbs:
aws-ecr: circleci/aws-ecr@8.2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
Expand Down Expand Up @@ -51,10 +54,65 @@ jobs:
# command: |
# make test-e2e

build_docker:
machine:
image: ubuntu-2204:2022.10.1
resource_class: large
steps:
- checkout
- aws-ecr/build-image:
push-image: false
dockerfile: Dockerfile
path: ./contrib/images/babylond-env/
build-path: ./
tag: "$CIRCLE_SHA1,$CIRCLE_TAG"
repo: "babylond"
- run:
name: Save Docker image to export it to workspace
command: |
docker save $(docker image ls --format '{{.Repository}}:{{.Tag}}') > /tmp/babylond.tar
- persist_to_workspace:
root: /tmp
paths:
- babylond.tar

push_docker:
machine:
image: ubuntu-2204:2022.10.1
resource_class: large
steps:
- attach_workspace:
at: /tmp
- run:
name: Load Docker image from workspace
command: |
docker load -i /tmp/babylond.tar
- aws-ecr/ecr-login:
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
region: "$AWS_REGION"
- aws-ecr/push-image:
registry-id: AWS_ECR_REGISTRY_ID
region: "$AWS_REGION"
repo: "babylond"
tag: "$CIRCLE_SHA1,$CIRCLE_TAG"

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
build-lint-test:
jobs:
- build
- build_docker:
filters:
tags:
only: /.*/
- push_docker:
requires:
- build_docker
filters:
tags:
only: /.*/
branches:
only:
- main