forked from corticometrics/fs-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildspec-infant.yml
67 lines (65 loc) · 3.47 KB
/
buildspec-infant.yml
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
# see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
version: 0.2
env:
shell: bash
# https://stackoverflow.com/questions/58216549/how-to-retrieve-secret-manager-data-in-buildspec-yaml
parameter-store:
DOCKERHUB_PASS_PARAM: /dockerhub-access-token-for-pwighton
FS_LICENSE_PARAM: /freesurfer-ci-license
phases:
install:
on-failure: ABORT
commands:
- export DOCKERHUB_PASS=$DOCKERHUB_PASS_PARAM
- export FS_LICENSE=$FS_LICENSE_PARAM
- docker login --username pwighton --password $DOCKERHUB_PASS
# even though we use `pwighton/neurodocker:latest` to create the Dockerfile for now
# (until https://github.com/pwighton/neurodocker/tree/20210226-fs-source is merged; but that is
# based off of, and waiting on https://github.com/ReproNim/neurodocker/pull/378, then we can
# switch to `repronim/neurodocker:latest`)
# we need still need neurodocker outside of docker for `neurodocker minify`
- pip install neurodocker
build:
on-failure: ABORT
commands:
- ND="docker run pwighton/neurodocker:latest" FS_LICENSE_BASE64=$FS_LICENSE make fs-infant-dev
# Docker push now while debugging buildspec
- docker push pwighton/fs-infant-dev:latest
#!! TO save time when debugging the test/minify (comment out `make fs-infant-dev` and `docker push` above
#!!- docker pull pwighton/fs-infant-dev:latest
# Minify this beast of a container
post_build:
on-failure: ABORT
commands:
# Setup test/minify env
- aws configure set region 'us-east-2'
- export FS_DATAIN=/tmp/run/fs-datain
- export FS_SUB=/tmp/run/fs-sub
- export FS_INFANT_MODEL=/tmp/run/fs-infant-model
- export SUB=sub-CC00656XX13-ses-217601
- export SUB_S3_IN=s3://fs-infant/test/smoke/sub-CC00656XX13_ses-217601_desc-restore_space-T2w_T1w.nii.gz
- export FS_INFANT_MODEL_S3_IN=s3://fs-infant/model/dev/
- mkdir -p ${FS_DATAIN}
- mkdir -p ${FS_SUB}
- mkdir -p ${FS_INFANT_MODEL}
- rm -rf ${FS_SUB}/${SUB}
- mkdir -p ${FS_SUB}/${SUB}
- aws s3 cp ${SUB_S3_IN} ${FS_SUB}/${SUB}/mprage.nii.gz
- aws s3 cp --recursive --include '*' ${FS_INFANT_MODEL_S3_IN} ${FS_INFANT_MODEL}/
### END Setup test/minify env
# the test command (without minify)
# pw 2021/05/20: not sure why I have to specificy the entrypoint explicitly... wont work without it tho
#- docker run --rm --entrypoint /bin/infant-container-entrypoint.bash -e SUBJECTS_DIR=/ext/fs-subjects -v ${FS_SUB}:/ext/fs-subjects -v ${FS_INFANT_MODEL}:/opt/fs-infant-model pwighton/fs-infant-dev:latest infant_recon_all --s sub-CC00656XX13-ses-217601 --age 0
# the minify commands
- cmd1="/bin/infant-container-entrypoint.bash"
- cmd2="infant_recon_all --s sub-CC00656XX13-ses-217601 --age 0"
# prep for minify
- docker run --security-opt seccomp:unconfined --rm -it -d --name container-to-min --entrypoint /bin/bash -e SUBJECTS_DIR=/ext/fs-subjects -v ${FS_SUB}:/ext/fs-subjects -v ${FS_INFANT_MODEL}:/opt/fs-infant-model pwighton/fs-infant-dev:latest
- sleep 1
# minify
- yes | neurodocker-minify --container container-to-min --dirs-to-prune /opt --commands "$cmd1" "$cmd2"
# export minified container
- docker export container-to-min | docker import - pwighton/fs-infant-dev:min
# push containers, if all went well
- docker push pwighton/fs-infant-dev:latest
- docker push pwighton/fs-infant-dev:min