Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Refactor Docker build process #2982

Merged
merged 19 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 53 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ orbs:
jobs:
build_clean:
<<: *machine_defaults
environment:
DOCKER_BUILDKIT: 1
steps:
- checkout:
path: *src
Expand All @@ -144,17 +146,19 @@ jobs:

build:
<<: *machine_defaults
environment:
DOCKER_BUILDKIT: 1
steps:
- checkout:
path: *src
- run: *check_skip_job
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v0--{{ .Revision }}
- build-v0-{{ .Branch }}-
- build-v0-master-
- build-v0-
- build-v2-{{ .Branch }}-{{ .Revision }}
- build-v2--{{ .Revision }}
- build-v2-{{ .Branch }}-
- build-v2-master-
- build-v2-
paths:
- /tmp/docker
- /tmp/images
Expand All @@ -172,6 +176,14 @@ jobs:
name: Pull Ubuntu/jammy image
command: |
set +e
# Source layers if available
docker pull localhost:5000/downloader
docker pull localhost:5000/freesurfer
docker pull localhost:5000/afni
docker pull localhost:5000/ants
docker pull localhost:5000/workbench
docker pull localhost:5000/micromamba

docker pull localhost:5000/ubuntu
success=$?
set -e
Expand Down Expand Up @@ -219,7 +231,14 @@ jobs:
e=1 && for i in {1..5}; do
docker build --rm \
--cache-from=nipreps/fmriprep \
--cache-from=localhost:5000/downloader \
--cache-from=localhost:5000/freesurfer \
--cache-from=localhost:5000/afni \
--cache-from=localhost:5000/ants \
--cache-from=localhost:5000/workbench \
--cache-from=localhost:5000/micromamba \
-t nipreps/fmriprep:latest \
--target fmriprep \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg VERSION="${CIRCLE_TAG:-$THISVERSION}" . \
Expand All @@ -240,12 +259,28 @@ jobs:
echo "BUILT: \"$BUILT_VERSION\""
set -e
test "$BUILT_VERSION" = "$THISVERSION"
- run:
name: Build and tag stages
no_output_timeout: 40m
command: |
docker build -t localhost:5000/downloader --target downloader .
docker build -t localhost:5000/freesurfer --target freesurfer .
docker build -t localhost:5000/afni --target afni .
docker build -t localhost:5000/ants --target ants .
docker build -t localhost:5000/workbench --target workbench .
docker build -t localhost:5000/micromamba --target micromamba .
- run:
name: Docker push to local registry
no_output_timeout: 40m
command: |
docker tag nipreps/fmriprep:latest localhost:5000/fmriprep
docker push localhost:5000/fmriprep
docker push localhost:5000/downloader
docker push localhost:5000/freesurfer
docker push localhost:5000/afni
docker push localhost:5000/ants
docker push localhost:5000/workbench
docker push localhost:5000/micromamba
- run:
name: Docker registry garbage collection
command: |
Expand All @@ -257,7 +292,7 @@ jobs:
paths:
- src/fmriprep
- save_cache:
key: build-v0-{{ .Branch }}-{{ .Revision }}
key: build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand Down Expand Up @@ -390,7 +425,7 @@ jobs:
at: /tmp
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand Down Expand Up @@ -463,7 +498,7 @@ jobs:
at: /tmp
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand Down Expand Up @@ -651,7 +686,7 @@ jobs:
at: /tmp
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand Down Expand Up @@ -767,7 +802,7 @@ jobs:
at: /tmp
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand All @@ -776,11 +811,11 @@ jobs:
- data-v0-{{ .Branch }}-{{ .Revision }}
- restore_cache:
keys:
- ds210-anat-v0-{{ .Branch }}-{{ .Revision }}
- ds210-anat-v0--{{ .Revision }}
- ds210-anat-v0-{{ .Branch }}-
- ds210-anat-v0-master-
- ds210-anat-v0-
- ds210-anat-v1-{{ .Branch }}-{{ .Revision }}
- ds210-anat-v1--{{ .Revision }}
- ds210-anat-v1-{{ .Branch }}-
- ds210-anat-v1-master-
- ds210-anat-v1-
- docker/install-docker-credential-helper
- run: *docker_auth
- run: *setup_docker_registry
Expand Down Expand Up @@ -808,7 +843,7 @@ jobs:
rm -rf /tmp/${DATASET}/work/reportlets
rm -rf /tmp/${DATASET}/derivatives/fmriprep
- save_cache:
key: ds210-anat-v0-{{ .Branch }}-{{ .Revision }}
key: ds210-anat-v1-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/ds210/work

Expand Down Expand Up @@ -873,7 +908,7 @@ jobs:
fi
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand All @@ -896,7 +931,7 @@ jobs:
- run: *check_skip_job
- restore_cache:
keys:
- build-v0-{{ .Branch }}-{{ .Revision }}
- build-v2-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker
- /tmp/images
Expand Down
Loading