1
1
version : 2.1
2
2
3
3
orbs :
4
-
5
-
6
- aws-cli :
circleci/[email protected]
7
- aws-ecr :
circleci/[email protected]
4
+
8
5
6
+ aws-cli :
circleci/[email protected]
9
7
10
8
# Workflow shortcuts
11
9
not_main : ¬_main
@@ -40,142 +38,7 @@ only_dev: &only_dev
40
38
- dev
41
39
42
40
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
-
47
41
jobs :
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
-
179
42
apollo :
180
43
machine :
181
44
image : ubuntu-2404:2024.05.1
@@ -326,9 +189,9 @@ jobs:
326
189
condition : << parameters.deploy >>
327
190
steps :
328
191
- 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
332
195
- run :
333
196
name : Package Lambda
334
197
# We bundle our code in a way that lambda can understand and execute
@@ -403,7 +266,7 @@ workflows:
403
266
- setup-deploy-params-prod
404
267
405
268
# Try building the ECS docker image on each branch
406
- - docker_build_new :
269
+ - pocket/docker_build :
407
270
<< : *not_dev_main
408
271
context : pocket
409
272
name : build_docker
@@ -419,7 +282,7 @@ workflows:
419
282
- build
420
283
421
284
# Build & Deploy the Dev Docker Image
422
- - docker_build_new :
285
+ - pocket/docker_build :
423
286
<< : *only_dev
424
287
context : pocket
425
288
name : build_docker_dev
@@ -452,7 +315,7 @@ workflows:
452
315
- build_docker_dev
453
316
454
317
# Build & Deploy the Prod Docker Image
455
- - docker_build_new :
318
+ - pocket/docker_build :
456
319
<< : *only_main
457
320
context : pocket
458
321
name : build_docker_prod
0 commit comments