Skip to content

Commit baf20c7

Browse files
authored
Merge pull request #216 from psu-libraries/p-pushwait-recs-from-ag
Add cluster parameters and improve Docker image handling
2 parents 96e99a0 + 822e4d3 commit baf20c7

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

.circleci/config.yml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ parameters:
3131
REGISTRY_HOST:
3232
type: string
3333
default: "harbor.k8s.libraries.psu.edu"
34+
CLUSTERS_DEV:
35+
type: string
36+
default: "uldev"
37+
CLUSTERS_PROD:
38+
type: string
39+
default: "prod"
3440

3541
commands:
3642

@@ -101,6 +107,10 @@ jobs:
101107
tag: $TAG
102108
extra_build_args: "--target production"
103109
use-buildkit: true
110+
- run:
111+
name: Save Docker image
112+
command: |
113+
docker save $REGISTRY_HOST/$REGISTRY_REPO:$TAG -o /tmp/docker-image.tar
104114
- run:
105115
name: Save image info for push job
106116
command: |
@@ -109,6 +119,7 @@ jobs:
109119
- persist_to_workspace:
110120
root: /tmp
111121
paths:
122+
- docker-image.tar
112123
- docker-image-info
113124

114125
push-image:
@@ -121,20 +132,17 @@ jobs:
121132
registry_host: << pipeline.parameters.REGISTRY_HOST >>
122133
steps:
123134
- setup_remote_docker:
124-
docker_layer_caching: true
135+
docker_layer_caching: false
125136
- checkout
126137
- compute-docker-tag
127138
- attach_workspace:
128139
at: /tmp
140+
- run:
141+
name: Load Docker image
142+
command: |
143+
docker load -i /tmp/docker-image.tar
129144
- docker/check:
130145
registry: $REGISTRY_HOST
131-
- docker/build:
132-
image: $REGISTRY_REPO
133-
registry: $REGISTRY_HOST
134-
tag: $TAG
135-
extra_build_args: "--target production"
136-
use-buildkit: true
137-
cache_from: $REGISTRY_REPO:$TAG
138146
- docker/push:
139147
image: $REGISTRY_REPO
140148
registry: $REGISTRY_HOST
@@ -241,7 +249,7 @@ jobs:
241249
bundle _$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs)_ install
242250
- run:
243251
name: Build and run containers
244-
command: docker-compose -f docker-compose.yml build --no-cache && docker-compose -f docker-compose.yml up --force-recreate -d
252+
command: docker-compose -f docker-compose.yml build && docker-compose -f docker-compose.yml up --force-recreate -d
245253
- run:
246254
name: Wait for mysql to be ready
247255
command: docker-compose exec web bash ./wait_for_db.sh
@@ -250,7 +258,7 @@ jobs:
250258
command: docker-compose exec -T web bundle exec niftany
251259
- run:
252260
name: "Run tests"
253-
command: RAILS_ENV=test docker-compose exec -it web bundle exec rspec
261+
command: RAILS_ENV=test docker-compose exec -T web bundle exec rspec
254262

255263
workflows:
256264

@@ -283,21 +291,11 @@ workflows:
283291
name: deploy-application
284292
context:
285293
- org-global
286-
clusters: "uldev"
294+
clusters: << pipeline.parameters.CLUSTERS_DEV >>
287295
filters:
288296
branches:
289297
only:
290298
- main
291-
requires:
292-
- push-image
293-
- deploy-application:
294-
name: deploy-application
295-
context:
296-
- org-global
297-
clusters: "uldev"
298-
filters:
299-
branches:
300-
only:
301299
- /preview\/.*/
302300
requires:
303301
- push-image
@@ -315,7 +313,7 @@ workflows:
315313
- test-application
316314
- release-image:
317315
name: release-image
318-
clusters: "prod"
316+
clusters: << pipeline.parameters.CLUSTERS_PROD >>
319317
context:
320318
- org-global
321319
from_tag: "<< pipeline.git.revision >>"

0 commit comments

Comments
 (0)