Skip to content

Commit 6e4c757

Browse files
authored
Merge pull request miykael#151 from oesteban/enh/refactor-circle-workflow
FIX: Do not use Circle's premium layer caching
2 parents be1ea72 + 26edbb2 commit 6e4c757

File tree

1 file changed

+120
-29
lines changed

1 file changed

+120
-29
lines changed

.circleci/config.yml

Lines changed: 120 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,132 @@
11
version: 2
22
jobs:
33
build:
4-
docker:
5-
- image: docker:18.05.0-ce-git
4+
machine:
5+
image: circleci/classic:201808-01
66
steps:
7+
- restore_cache:
8+
keys:
9+
- build-v1-{{ .Branch }}-{{ epoch }}
10+
- build-v1-{{ .Branch }}-
11+
- build-v1-master-
12+
- build-v1-
13+
paths:
14+
- /tmp/docker
15+
- run:
16+
name: Set-up a Docker registry
17+
command: |
18+
docker run -d -p 5000:5000 --restart=always --name=registry \
19+
-v /tmp/docker:/var/lib/registry registry:2
20+
- run:
21+
name: Pull existing images
22+
command: |
23+
set +e
24+
docker pull localhost:5000/neurodebian
25+
success=$?
26+
set -e
27+
if [[ "$success" = "0" ]]; then
28+
echo "Pulling from local registry"
29+
docker tag localhost:5000/neurodebian neurodebian:stretch-non-free
30+
docker pull localhost:5000/nipype_tutorial
31+
docker tag localhost:5000/nipype_tutorial miykael/nipype_tutorial:latest
32+
else
33+
echo "Pulling from Docker Hub"
34+
docker pull neurodebian:stretch-non-free
35+
docker tag neurodebian:stretch-non-free localhost:5000/neurodebian
36+
docker push localhost:5000/neurodebian
37+
fi
38+
739
- checkout
40+
- run:
41+
name: Build Docker image & push to registry
42+
no_output_timeout: 60m
43+
command: |
44+
docker build --rm --cache-from=miykael/nipype_tutorial:latest \
45+
-t miykael/nipype_tutorial:latest .
46+
docker tag miykael/nipype_tutorial:latest localhost:5000/nipype_tutorial
47+
docker push localhost:5000/nipype_tutorial
48+
- run:
49+
name: Docker registry garbage collection
50+
command: |
51+
docker exec -it registry /bin/registry garbage-collect --delete-untagged \
52+
/etc/docker/registry/config.yml
53+
- save_cache:
54+
key: build-v1-{{ .Branch }}-{{ epoch }}
55+
paths:
56+
- /tmp/docker
57+
858
test_1:
9-
docker:
10-
- image: docker:18.05.0-ce-git
59+
machine:
60+
image: circleci/classic:201808-01
1161
steps:
12-
- checkout
13-
- setup_remote_docker:
14-
docker_layer_caching: true
62+
- restore_cache:
63+
keys:
64+
- build-v1-{{ .Branch }}-{{ epoch }}
65+
- build-v1-{{ .Branch }}-
66+
- build-v1-master-
67+
- build-v1-
68+
paths:
69+
- /tmp/docker
1570
- run:
16-
name: docker build 1
17-
no_output_timeout: 60m
71+
name: Set-up a Docker registry & pull
1872
command: |
19-
docker build -t miykael/nipype_tutorial:$(echo $CIRCLE_BRANCH | sed 's|/|_|g') .
73+
docker run -d -p 5000:5000 --restart=always --name=registry \
74+
-v /tmp/docker:/var/lib/registry registry:2
75+
docker pull localhost:5000/nipype_tutorial
76+
docker tag localhost:5000/nipype_tutorial miykael/nipype_tutorial:latest
2077
- run:
2178
name: run tests 1
2279
no_output_timeout: 120m
2380
command: |
24-
docker run -it --rm miykael/nipype_tutorial:$(echo $CIRCLE_BRANCH | sed 's|/|_|g') python /home/neuro/nipype_tutorial/test_notebooks.py 1
81+
docker run -it --rm miykael/nipype_tutorial:latest python /home/neuro/nipype_tutorial/test_notebooks.py 1
2582
test_2:
26-
docker:
27-
- image: docker:18.05.0-ce-git
83+
machine:
84+
image: circleci/classic:201808-01
2885
steps:
29-
- checkout
30-
- setup_remote_docker:
31-
docker_layer_caching: true
86+
- restore_cache:
87+
keys:
88+
- build-v1-{{ .Branch }}-{{ epoch }}
89+
- build-v1-{{ .Branch }}-
90+
- build-v1-master-
91+
- build-v1-
92+
paths:
93+
- /tmp/docker
3294
- run:
33-
name: docker build 2
34-
no_output_timeout: 60m
95+
name: Set-up a Docker registry & pull
3596
command: |
36-
docker build -t miykael/nipype_tutorial:$(echo $CIRCLE_BRANCH | sed 's|/|_|g') .
97+
docker run -d -p 5000:5000 --restart=always --name=registry \
98+
-v /tmp/docker:/var/lib/registry registry:2
99+
docker pull localhost:5000/nipype_tutorial
100+
docker tag localhost:5000/nipype_tutorial miykael/nipype_tutorial:latest
37101
- run:
38102
name: run tests 2
39103
no_output_timeout: 120m
40104
command: |
41-
docker run -it --rm miykael/nipype_tutorial:$(echo $CIRCLE_BRANCH | sed 's|/|_|g') python /home/neuro/nipype_tutorial/test_notebooks.py 2
105+
docker run -it --rm miykael/nipype_tutorial:latest python /home/neuro/nipype_tutorial/test_notebooks.py 2
42106
test_3:
43-
docker:
44-
- image: docker:18.05.0-ce-git
107+
machine:
108+
image: circleci/classic:201808-01
45109
steps:
46-
- checkout
47-
- setup_remote_docker:
48-
docker_layer_caching: true
110+
- restore_cache:
111+
keys:
112+
- build-v1-{{ .Branch }}-{{ epoch }}
113+
- build-v1-{{ .Branch }}-
114+
- build-v1-master-
115+
- build-v1-
116+
paths:
117+
- /tmp/docker
49118
- run:
50-
name: docker build 3
51-
no_output_timeout: 60m
119+
name: Set-up a Docker registry & pull
52120
command: |
53-
docker build -t miykael/nipype_tutorial:$(echo $CIRCLE_BRANCH | sed 's|/|_|g') .
121+
docker run -d -p 5000:5000 --restart=always --name=registry \
122+
-v /tmp/docker:/var/lib/registry registry:2
123+
docker pull localhost:5000/nipype_tutorial
124+
docker tag localhost:5000/nipype_tutorial miykael/nipype_tutorial:latest
54125
- run:
55126
name: run tests 3
56127
no_output_timeout: 120m
57128
command: |
58-
docker run -it --rm miykael/nipype_tutorial:$(echo $CIRCLE_BRANCH | sed 's|/|_|g') python /home/neuro/nipype_tutorial/test_notebooks.py 3
129+
docker run -it --rm miykael/nipype_tutorial:latest python /home/neuro/nipype_tutorial/test_notebooks.py 3
59130
60131
workflows:
61132
version: 2
@@ -71,3 +142,23 @@ workflows:
71142
- test_3:
72143
requires:
73144
- build
145+
146+
nightly:
147+
triggers:
148+
- schedule:
149+
cron: "0 10 * * *"
150+
filters:
151+
branches:
152+
only:
153+
- master
154+
jobs:
155+
- build
156+
- test_1:
157+
requires:
158+
- build
159+
- test_2:
160+
requires:
161+
- build
162+
- test_3:
163+
requires:
164+
- build

0 commit comments

Comments
 (0)