Hi,
I want to build an image in one job once and push it in another job rather than using build_and_push_image. It is because I am using matrix in CircleCI to push image to 10 AWS regions so if I was to use build_and_push_image with matrix, it would have built image 10 times as well which is waste of time. This is why I am aiming to split image building and pushing into two different jobs. Note: I think this is how it works with this orb but If I am misunderstanding please let me know.
Is there a way to manage this requirement using circleci/aws-ecr or do I have to do some funky manual work?
Thank you
**Old version**
version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@9.7.0
jobs:
build-and-push:
parameters:
aws-region:
type: string
docker:
- image: cimg/base:stable
steps:
- checkout
- aws-ecr/build_and_push_image:
repo: my-app-repo
tag: ${CIRCLE_SHA1},latest
region: << parameters.aws-region >>
dockerfile: Dockerfile
workflows:
version: 2
build-and-push-matrix:
jobs:
- build-and-push:
matrix:
parameters:
aws-region:
- us-east-1
- us-west-2
- eu-west-1
- ...
**Aiming for**
version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@9.7.0
jobs:
build:
docker:
- image: cimg/base:stable
steps:
- Build here ...
push:
parameters:
aws-region:
type: string
docker:
- image: cimg/base:stable
steps:
- Push here ...
workflows:
version: 2
build-and-push:
jobs:
- build:
...
- push:
...
matrix:
parameters:
aws-region:
- us-east-1
- us-west-2
- eu-west-1
- ...