11version : 2.1
22
33orbs :
4- pocket : pocket/circleci-orbs@2.1.2
5-
6- aws-cli : circleci/aws-cli@5.1.0
7- aws-ecr : circleci/aws-ecr@9.3.4
4+ pocket : pocket/circleci-orbs@2.3.0
85
6+ aws-cli : circleci/aws-cli@2.0.6
97
108# Workflow shortcuts
119not_main : ¬_main
@@ -40,142 +38,7 @@ only_dev: &only_dev
4038 - dev
4139
4240
43- # ------------------------------------------------------------------------------
44- # docker_build_new is based on the following Pocket orb, and works with the latest aws-ecr orb.
45- # https://github.com/Pocket/circleci-orbs/blob/main/src/jobs/docker_build.yml
46-
4741jobs :
48- docker_build_new :
49- description : >
50- Build and/or push docker image to ECR. Runs codebuild if specified ECR does not exist to create it
51- parameters :
52- aws-access-key-id :
53- description : ' AWS access key id environment variable'
54- type : string
55- aws-region :
56- description : ' AWS region environment variable'
57- type : env_var_name # Use env_var_name to fetch the value dynamically
58- default : AWS_DEFAULT_REGION
59- aws-secret-access-key :
60- description : ' AWS secret access key environment variable'
61- type : string
62- aws-account-id :
63- description : ' AWS Account ID'
64- type : string
65- codebuild-project-name :
66- description : ' The CodeBuild project name'
67- type : string
68- default : ' '
69- codebuild-project-branch :
70- description : ' The git branch to build'
71- type : string
72- default : ' '
73- docker-image :
74- description : ' Docker image to use for the job'
75- type : string
76- default : cimg/base:stable
77- ecr-url :
78- description : ' The ECR URL'
79- type : string
80- extra-build-args :
81- description : ' Extra flags to pass to docker build'
82- type : string
83- default : ' --build-arg GIT_SHA=${CIRCLE_SHA1}'
84- path :
85- description : ' Path to the directory containing your Dockerfile and build context.'
86- type : string
87- default : ' /tmp/workspace/app_prod'
88- push :
89- description : ' Whether or not to push the code'
90- type : boolean
91- default : false
92- repo-name :
93- description : ' The ECR repo name'
94- type : string
95- tag :
96- description : ' The docker tag name'
97- type : string
98- default : ' latest,${CIRCLE_SHA1}'
99- workspace :
100- description : ' Path to CircleCI workspace to attach for the build'
101- type : string
102- default : ' /tmp/workspace'
103- remote-docker-version :
104- type : string
105- default : ' 20.10.24'
106- description : ' Specific remote docker version'
107- remote-docker-layer-caching :
108- type : boolean
109- default : false
110- description : ' Enable Docker layer caching if using remote Docker engine.'
111-
112- docker :
113- - image : << parameters.docker-image >>
114- steps :
115- - aws-cli/setup :
116- aws_access_key_id : << parameters.aws-access-key-id >>
117- aws_secret_access_key : << parameters.aws-secret-access-key >>
118- region : " ${<< parameters.aws-region >>}"
119- - run :
120- name : Setup Environment Variables
121- command : |
122- echo 'export AWS_ECR_ACCOUNT_URL="<< parameters.ecr-url >>"' >> $BASH_ENV
123- echo 'export AWS_REGION="<< parameters.aws-region >>"' >> $BASH_ENV
124- echo 'export REPO_NAME="<< parameters.repo-name >>"' >> $BASH_ENV
125- echo 'export CODEBUILD_PROJECT_NAME="<< parameters.codebuild-project-name >>"' >> $BASH_ENV
126- echo 'export CODEBUILD_PROJECT_BRANCH="<< parameters.codebuild-project-branch >>"' >> $BASH_ENV
127- - attach_workspace :
128- at : << parameters.workspace >>
129- - when :
130- condition : << parameters.push >>
131- steps :
132- - run :
133- name : Run CodeBuild for ECR
134- command : |
135- # Your script or commands to run CodeBuild if necessary
136- echo "Running CodeBuild for ECR..."
137- - setup_remote_docker :
138- version : << parameters.remote-docker-version >>
139- docker_layer_caching : << parameters.remote-docker-layer-caching >>
140- - aws-ecr/build_and_push_image :
141- account_id : << parameters.aws-account-id >>
142- auth :
143- - aws-cli/setup :
144- aws_access_key_id : << parameters.aws-access-key-id >>
145- aws_secret_access_key : << parameters.aws-secret-access-key >>
146- region : << parameters.aws-region >>
147- checkout : false
148- repo : << parameters.repo-name >>
149- path : << parameters.path >>
150- build_path : << parameters.path >>
151- tag : << parameters.tag >>
152- extra_build_args : << parameters.extra-build-args >>
153- platform : ' linux/amd64,linux/arm64'
154- region : " ${<< parameters.aws-region >>}"
155- - unless :
156- condition : << parameters.push >>
157- steps :
158- - setup_remote_docker :
159- version : << parameters.remote-docker-version >>
160- docker_layer_caching : << parameters.remote-docker-layer-caching >>
161- - aws-cli/setup :
162- aws_access_key_id : << parameters.aws-access-key-id >>
163- aws_secret_access_key : << parameters.aws-secret-access-key >>
164- region : << parameters.aws-region >>
165- - aws-ecr/build_image :
166- account_id : << parameters.aws-account-id >>
167- repo : << parameters.repo-name >>
168- path : << parameters.path >>
169- build_path : << parameters.path >>
170- tag : << parameters.tag >>
171- extra_build_args : << parameters.extra-build-args >>
172- platform : ' linux/amd64,linux/arm64'
173- region : " ${<< parameters.aws-region >>}"
174- push_image : false
175-
176- # -----------------------------------------------------------------------
177- # recommendation-api jobs
178-
17942 apollo :
18043 machine :
18144 image : ubuntu-2404:2024.05.1
@@ -326,9 +189,9 @@ jobs:
326189 condition : << parameters.deploy >>
327190 steps :
328191 - aws-cli/setup :
329- aws_access_key_id : << parameters.env_capital_name >>_AWS_ACCESS_KEY
330- aws_secret_access_key : << parameters.env_capital_name >>_AWS_SECRET_ACCESS_KEY
331- region : ${ << parameters.env_capital_name >>_AWS_DEFAULT_REGION}
192+ aws-access-key-id : << parameters.env_capital_name >>_AWS_ACCESS_KEY
193+ aws-secret-access-key : << parameters.env_capital_name >>_AWS_SECRET_ACCESS_KEY
194+ aws- region : << parameters.env_capital_name >>_AWS_DEFAULT_REGION
332195 - run :
333196 name : Package Lambda
334197 # We bundle our code in a way that lambda can understand and execute
@@ -403,7 +266,7 @@ workflows:
403266 - setup-deploy-params-prod
404267
405268 # Try building the ECS docker image on each branch
406- - docker_build_new :
269+ - pocket/docker_build :
407270 << : *not_dev_main
408271 context : pocket
409272 name : build_docker
@@ -419,7 +282,7 @@ workflows:
419282 - build
420283
421284 # Build & Deploy the Dev Docker Image
422- - docker_build_new :
285+ - pocket/docker_build :
423286 << : *only_dev
424287 context : pocket
425288 name : build_docker_dev
@@ -452,7 +315,7 @@ workflows:
452315 - build_docker_dev
453316
454317 # Build & Deploy the Prod Docker Image
455- - docker_build_new :
318+ - pocket/docker_build :
456319 << : *only_main
457320 context : pocket
458321 name : build_docker_prod
0 commit comments