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

ENH: generate Dockerfiles with neurodocker + migrate to CircleCI 2.0 #2202

Merged
merged 17 commits into from
Nov 15, 2017

Conversation

kaczmarj
Copy link
Collaborator

@kaczmarj kaczmarj commented Oct 2, 2017

Fixes #2144.

Changes proposed in this pull request:

Addresses (or will address) these items from the original issue:

  1. generate dockerfiles using neurodocker
  2. check if dockerfile hash has changed or force update is set (need to determine this from PR)
  3. if force update, regenerate dockerfile
  4. build docker image if needed or reload minimized image
  5. run all tests via neurodocker reprozip (in parallel)
  6. combine all reprozip packs into a single pack
  7. generate minimized docker image using reprounzip and cache this image

Other changes:

  • Migrate to CircleCI 2.0.

This is a work-in-progress. It would be great to have some feedback on what I have so far, namely dockerfile generation and the migration to circleci 2.0.

Parts of the code refer to my personal dockerhub repo (kaczmarj/nipype) but those will be changed when this PR is closer to complete. Also, the master neurodocker docker image is used now, but I will change this to v0.3.2 once I release that version.

I am in the process of reworking neurodocker-reprozip's container-minimization functionality (VIDA-NYU/reprozip#274). I hope to finish that soon for this PR. I have already added a command to merge reprozip pack files (ReproNim/neurodocker#69).

Just to note, I propose using neurodebian:stretch-non-free as the base image, instead of ubuntu:xenial-20161213.

Todo

  • generate dockerfiles using neurodocker
  • check if dockerfile hash has changed or force update is set (need to determine this from PR)
    • checking is implemented, but forcing update is not.
  • if force update, regenerate dockerfile
  • build docker image if needed or reload minimized image
  • run all tests via neurodocker reprozip (in parallel)
  • combine all reprozip packs into a single pack
  • generate minimized docker image using reprounzip and cache this image

jakubk added 2 commits October 2, 2017 18:57
Rename base.Dockerfile to Dockerfile.base to conform to moby style. For now, the master Neurodocker Docker image is used, but a versioned image will be used once a newer Neurodocker version is released.
The specification for CircleCI 2.0 is stored in `.circleci/config.yml` instead of in `circle.yml`.

Todo:
- Run tests. For now, images are built and pushed, but no tests are run.
- Minimize containers with neurodocker reprozip. This functionality will be updated soon. See discussion in VIDA-NYU/reprozip#274.
@kaczmarj
Copy link
Collaborator Author

kaczmarj commented Oct 2, 2017

Please see https://circleci.com/gh/kaczmarj/nipype/182 for an example of the CircleCI run on my fork.

fusefat g++ git graphviz make ruby unzip xvfb \
--add-to-entrypoint "source /etc/fsl/fsl.sh" \
--env ANTSPATH='/usr/lib/ants' PATH='/usr/lib/ants:$PATH' \
--c3d version=1.0.0 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latest version of convert3d might be available in neurodebian

@satra
Copy link
Member

satra commented Oct 30, 2017

@kaczmarj - please make sure to merge with master, when sending an update.

@kaczmarj
Copy link
Collaborator Author

@satra - i'll be sure to do that. i am waiting on VIDA-NYU/reprozip#281. At the moment, reprozip trace returns status code 0 even if a traced command failed.

jakubk added 8 commits November 6, 2017 14:49
- install dependency codecov
- update nipype/info.py if CIRCLE_TAG is set
- retry docker image builds
- download test data
- fix workdir permission denied issue
- save all docker images to single tarball
- pipe dockerhub password to `docker login`
- push all docker images to docker hub on success
Use this file to prune Dockerfiles before getting their hash.

- remove empty lines, comments, and timestamp
@kaczmarj
Copy link
Collaborator Author

kaczmarj commented Nov 6, 2017

In an effort to complete this PR in time for the release of version 0.14, minimizing containers with ReproZip will be done in a separate PR. The tests might have to be re-balanced in another PR.

Does it seem reasonable to use CircleCI's option to rebuild without cache to force a rebuild of the base Docker image?

Notes

Copy link
Member

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty nice - thanks!


compare_base_dockerfiles:
docker:
- image: docker:17.09.0-ce-git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we update this to 17.10.0-ce for the chown flag

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point, although the change would be in the machine executor of build_and_test. i can change that to circleci/classic:201710-02 (more info on machine executors).

ash prune_dockerfile.sh Dockerfile.base > /tmp/docker/Dockerfile.base-pruned
- restore_cache:
# TODO: change this to 'master' after we are sure this works.
key: dftest-v5-enh/circleci-neurodocker-{{ checksum "/tmp/docker/Dockerfile.base-pruned" }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be changed now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i will change this

# TODO: remove `docker pull` once once caching works.
command: |
# bash /tmp/docker/get_base_image.sh
docker pull kaczmarj/nipype:base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also has to be changed. this was in place to cut down on testing time when base docker image didn't change but the cache wasn't set yet

e=1 && for i in {1..5}; do
docker build \
--rm=false \
--tag kaczmarj/nipype:latest \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nipype/nipype

e=1 && for i in {1..5}; do
docker build \
--rm=false \
--tag kaczmarj/nipype:py27 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nipype/nipype

no_output_timeout: 120m
command: |
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
docker push kaczmarj/nipype:base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nipype/nipype

filters:
branches:
# TODO: change this to master after we are sure this works.
only: enh/circleci-neurodocker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoo!

fi

# TODO: change this image name
DOCKER_IMAGE="kaczmarj/nipype"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping here

Dockerfile Outdated

COPY ["docker/files/run_builddocs.sh", "docker/files/run_examples.sh", "docker/files/run_pytests.sh", "nipype/external/fsl_imglob.py", "/usr/bin/"]
Copy link
Member

@mgxd mgxd Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't feel too strongly about changing this, but maybe we can take advantage of --chown flag now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can do that. although this would require an update to neurodocker. could this be done in a future pr?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

# neurodebian:stretch-non-free pulled on November 3, 2017
BASE_IMAGE="neurodebian@sha256:7590552afd0e7a481a33314724ae27f76ccedd05ffd7ac06ec38638872427b9b"

NIPYPE_BASE_IMAGE="kaczmarj/nipype:base"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nipype/nipype

jakubk added 4 commits November 13, 2017 11:27
- use master branch for caching
- replace kaczmarj/nipype with nipype/nipype
- reset cache prefixes
- use latest docker (v17.10.0-ce) containers and machine
- use environment variable to determine whether to pull or build base image
- save docker images to tar.gz if on master branch (deploying)
- use fastest gzip compression (gives good ratio of speed/compression)
@kaczmarj kaczmarj changed the title WIP+ENH: use neurodocker to generate and minimize containers for testing ENH: generate Dockerfiles with neurodocker + migrate to CircleCI 2.0 Nov 14, 2017
@mgxd mgxd requested a review from satra November 14, 2017 16:25
@satra
Copy link
Member

satra commented Nov 14, 2017

i think this looks good - one question: since we are generating the dockerfile do we need to store it?

@kaczmarj
Copy link
Collaborator Author

The Dockerfiles are not generated during the testing. I was thinking that someone would generate the Dockerfiles if needed, commit the changes, and push. The testing would use those Dockerfiles.

Do you want CircleCI to generate the Dockerfiles?

@satra
Copy link
Member

satra commented Nov 14, 2017

@kaczmarj - since the testing uses docker and has a script that generates the dockerfile, can't that be generated during testing rather than being in the repo?

@kaczmarj
Copy link
Collaborator Author

That makes sense. Should both the base and main Dockerfiles be generated in CircleCI? Or would you like to have the main Dockerfile in the repo?

@satra
Copy link
Member

satra commented Nov 14, 2017

i think anything that can be generated should be generated otherwise it can go out of sync.

@kaczmarj kaczmarj force-pushed the enh/circleci-neurodocker branch from 9f6544f to a189fb5 Compare November 15, 2017 02:15
- do not store dockerfiles in repo
- cache base dockerfile in deploy step that was generated in `compare_base_dockerfiles` step
- use global `working_directory`
@kaczmarj kaczmarj force-pushed the enh/circleci-neurodocker branch from a189fb5 to 28547cc Compare November 15, 2017 02:26
@kaczmarj
Copy link
Collaborator Author

@satra - dockerfiles are generated in CircleCI now, and I removed them from the repo.

I should also mention that If the base Dockerfile is ever reverted to a previous cached version, the CircleCI cache prefix (i.e., 'dockerfile-cache-v1') should be changed (perhaps incremented to 'dockerfile-cache-v2'). Here are the two relevant lines 1 and 2.

If the base Dockerfile is reverted to be the same (identical, not considering comments and empty lines) as a previous, cached base Dockerfile, the old cached Dockerfile will be found and the current base Docker image will be pulled. This is not desirable, but it happens because CircleCI's caches are immutable.

@mgxd
Copy link
Member

mgxd commented Nov 15, 2017

@kaczmarj don't forget to add yourself to the .zenodo file as well

@mgxd mgxd merged commit edaf222 into nipy:master Nov 15, 2017
@mgxd mgxd removed the needs-review label Nov 16, 2017
@effigies effigies mentioned this pull request Jan 20, 2018
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH proposal: use neurodocker to generate and minimize containers for testing
3 participants