-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsymfony.yaml
322 lines (321 loc) · 13.7 KB
/
symfony.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
version: 2.1
description: |
Help to deploy symfony projects
display:
home_url: https://github.com/donkeycode/circle-orbs
source_url: https://github.com/donkeycode/circle-orbs
orbs:
docker: donkeycode/[email protected]
node: donkeycode/[email protected]
utils: donkeycode/[email protected]
executors:
default:
description: |
Php nginx executor
docker:
- image: donkeycode/php-nginx-symfony:<<parameters.image_tag>>
parameters:
image_tag:
default: 8.2-fpm
description: |
Pick a specific donkeycode/php-nginx-symfony image variant: https://hub.docker.com/r/donkeycode/php-nginx-symfony/tags
type: string
jobs:
build:
description: |
Build symfony project
executor: docker/default
parameters:
docker_folder:
default: docker
description: The docker folder
type: string
docker_registry:
default: ${DOCKER_REGISTRY}/
description: The docker registry base
type: string
dockerfile_base_name:
default: Dockerfile-php
description: The docker base name eg Dockerfile-api
type: string
dockerfile_crontab_name:
default: Dockerfile-php-crontab
description: The docker base name eg Dockerfile-api
type: string
image_base_name:
description: The docker base name eg project/api
type: string
image_crontab_name:
default: project/crontab
description: The docker crontab name eg project/api-crontab
type: string
symfony_folder:
default: apps/api
description: The symfony base directory
type: string
use_crontab:
default: false
description: |
Is the project need crontab image
type: boolean
use_docker_login:
default: false
description: Set true to use docker login
type: boolean
use_ecr:
default: true
description: Set true to use aws ecr
type: boolean
use_encore:
default: false
description: |
Is the project need to install encore deps ?
type: boolean
steps:
- utils/install_git
- run:
command: apk add openssh
- checkout
- setup_remote_docker:
docker_layer_caching: true
- restore_cache:
keys:
- v1-dependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/composer.lock" }}
name: Get site deps
- when:
condition: <<parameters.use_encore>>
steps:
- restore_cache:
keys:
- v1-npmdependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/package-lock.json" }}
name: Get npm deps
- restore_cache:
keys:
- v1-public-<<parameters.symfony_folder>>-{{ .Revision }}
name: Get public cache
- when:
condition: <<parameters.use_ecr>>
steps:
- docker/ecr_login
- when:
condition: <<parameters.use_docker_login>>
steps:
- docker/login
- run:
command: |
source ~/project/.circleci/determine_env.sh
docker build -t <<parameters.docker_registry>><<parameters.image_base_name>>:$CIRCLE_SHA1 -f ~/project/<<parameters.docker_folder>>/<<parameters.dockerfile_base_name>> .
name: Build app
working_directory: ~/project
- when:
condition:
or:
- <<parameters.use_ecr>>
- <<parameters.use_docker_login>>
steps:
- run:
command: |
source ~/project/.circleci/determine_env.sh
docker push <<parameters.docker_registry>><<parameters.image_base_name>>:$CIRCLE_SHA1
name: Push App
working_directory: ~/project
- when:
condition:
and:
- not: <<parameters.use_ecr>>
- not: <<parameters.use_docker_login>>
steps:
- run:
command: "source ~/project/.circleci/determine_env.sh\nmkdir -p docker-images\ndocker save -o docker-images/<<parameters.image_base_name>>.$CIRCLE_SHA1.tar <<parameters.image_base_name>>:$CIRCLE_SHA1 \n"
name: Save image to workspace
working_directory: ~/project
- when:
condition: <<parameters.use_crontab>>
steps:
- run:
command: |
source ~/project/.circleci/determine_env.sh
docker build -t <<parameters.docker_registry>><<parameters.image_crontab_name>>:$CIRCLE_SHA1 -f ~/project/<<parameters.docker_folder>>/<<parameters.dockerfile_crontab_name>> .
name: Build crontab
working_directory: ~/project
- when:
condition:
and:
- <<parameters.use_crontab>>
- or:
- <<parameters.use_ecr>>
- <<parameters.use_docker_login>>
steps:
- run:
command: "source ~/project/.circleci/determine_env.sh \ndocker push <<parameters.docker_registry>><<parameters.image_crontab_name>>:$CIRCLE_SHA1\n"
name: Push crontab
working_directory: ~/project
- when:
condition:
and:
- <<parameters.use_crontab>>
- not: <<parameters.use_ecr>>
- not: <<parameters.use_docker_login>>
steps:
- run:
command: "source ~/project/.circleci/determine_env.sh\ndocker save -o docker-images/<<parameters.image_crontab_name>>.$CIRCLE_SHA1.tar <<parameters.image_crontab_name>>:$CIRCLE_SHA1 \n"
name: Save image to workspace
working_directory: ~/project
- when:
condition:
and:
- not: <<parameters.use_ecr>>
- not: <<parameters.use_docker_login>>
steps:
- persist_to_workspace:
paths:
- docker-images
root: ~/project
- store_artifacts:
path: ~/project/docker-images
phpunit:
description: |
Prepare symfony project
executor: default
parameters:
image_tag:
default: 8.2-fpm
description: |
Pick a specific donkeycode/php-nginx-symfony image variant: https://hub.docker.com/r/donkeycode/php-nginx-symfony/tags
type: string
prepare_command:
default: |
echo "Define your prepare command to setup database or anything you want"
description: |
Define your prepare command to setup database or anything you want
type: string
symfony_folder:
default: apps/api
description: The symfony base directory
type: string
use_encore:
default: false
description: |
Is the project need to install encore deps ?
type: boolean
steps:
- utils/install_git
- run:
command: apk add openssh
- checkout
- restore_cache:
keys:
- v1-dependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/composer.lock" }}
name: Get site deps
- when:
condition: <<parameters.use_encore>>
steps:
- restore_cache:
keys:
- v1-npmdependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/package-lock.json" }}
name: Get npm deps
- restore_cache:
keys:
- v1-public-<<parameters.symfony_folder>>-{{ .Revision }}
name: Get public cache
- run:
command: <<parameters.prepare_command>>
name: Prepare env for phpunit
- run:
command: cd <<parameters.symfony_folder>> && php bin/phpunit
name: Run phpunit
prepare:
description: |
Prepare symfony project
executor: default
parameters:
image_tag:
default: 8.2-fpm
description: |
Pick a specific donkeycode/php-nginx-symfony image variant: https://hub.docker.com/r/donkeycode/php-nginx-symfony/tags
type: string
symfony_folder:
default: apps/api
description: The symfony base directory
type: string
use_encore:
default: false
description: |
Is the project need to install encore deps ?
type: boolean
steps:
- utils/install_git
- run:
command: apk add openssh
- checkout
- restore_cache:
keys:
- v1-dependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/composer.lock" }}
- v1-dependencies-<<parameters.symfony_folder>>-
- run:
command: composer self-update --2
name: Composer 2
working_directory: ~/project/<<parameters.symfony_folder>>
- run:
command: composer install --ignore-platform-reqs --no-interaction
name: Install site deps
working_directory: ~/project/<<parameters.symfony_folder>>
- when:
condition: <<parameters.use_encore>>
steps:
- node/install
- restore_cache:
keys:
- v1-npmdependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/package-lock.json" }}
- v1-npmdependencies-<<parameters.symfony_folder>>-
- run:
command: npm install
name: Install node deps
working_directory: ~/project/<<parameters.symfony_folder>>
- save_cache:
key: v1-npmdependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/package-lock.json" }}
paths:
- <<parameters.symfony_folder>>/node_modules
- run:
command: npm run build
name: Build assets
working_directory: ~/project/<<parameters.symfony_folder>>
- run:
command: bin/console assets:install
name: Reinstall assets
working_directory: ~/project/<<parameters.symfony_folder>>
- save_cache:
key: v1-dependencies-<<parameters.symfony_folder>>-{{ checksum "~/project/<<parameters.symfony_folder>>/composer.lock" }}
paths:
- <<parameters.symfony_folder>>/vendor
- save_cache:
key: v1-public-<<parameters.symfony_folder>>-{{ .Revision }}
paths:
- <<parameters.symfony_folder>>/public
examples:
example:
description: |
Sample example description.
usage:
version: "2.1"
orbs:
symfony: donkeycode/[email protected]
workflows:
use-my-orb:
jobs:
- symfony/prepare:
image_tag: 8.2-fpm
name: Prepare Test
symfony_folder: apps/api
use_encore: true
- symfony/build:
context: rancher-2
dockerfile_base_name: Dockerfile-php
dockerfile_crontab_name: Dockerfile-php-crontab
image_base_name: testorbs/api
image_crontab_name: testorbs/api-crontab
name: Build Test
requires:
- Prepare Test
use_crontab: true
use_encore: true