Merge release-2019 into master
[alexxy/gromacs.git] / python_packaging / docker / ci.dockerfile
1 # Provide an easy-to-reproduce environment in which to test full Python functionality.
2
3 # Run with default command or specify one of the scripts to be executed through the entrypoint.
4 #
5 #    docker run --rm -ti gmxapi/ci-mpich:fr1 integrationtest
6 #
7 # Building:
8 #
9 # Requires Docker 17.05 or higher.
10 #
11 # Note to maintainers:
12 # Build from the GROMACS image at the current fork point. Tag with the feature
13 # name or the current revision.
14 #
15 #    FORKPOINT=$(git show -s --pretty=format:"%h" `git merge-base gerrit_master HEAD`)
16 #    REF=`git show -s --pretty=format:"%h"`
17 #    # or
18 #    REF="fr1"
19 #    docker build -t gmxapi/ci-mpich:${REF} --build-arg REF=${FORKPOINT} -f ci.dockerfile ..
20 #
21
22 #
23 # Use gromacs installation from gmxapi/gromacs image
24 #
25
26 ARG REF=latest
27 FROM gmxapi/gromacs-mpich:$REF as gromacs
28 # This intermediate is necessary because the COPY command does not support syntax like the following:
29 #COPY --from=gmxapi/gromacs:$REF /usr/local/gromacs /usr/local/gromacs
30
31 FROM gmxapi/gromacs-dependencies-mpich
32
33 RUN apt-get update && \
34     apt-get -yq --no-install-suggests --no-install-recommends install \
35         python3 \
36         python3-dev \
37         python3-venv && \
38     rm -rf /var/lib/apt/lists/*
39
40 # TODO: Use non-system Python installations for explicit version coverage.
41 # Consider pyenv for generic management of Python environment.
42
43 ENV CMAKE_ROOT /usr/local/cmake
44 ENV PATH $CMAKE_ROOT/bin:$PATH
45
46 RUN groupadd -r testing && useradd -m -s /bin/bash -g testing testing
47
48 USER testing
49
50 ENV VENV /home/testing/venv
51 RUN python3 -m venv $VENV
52 RUN . $VENV/bin/activate && \
53     pip install --no-cache-dir --upgrade pip setuptools
54
55 ADD --chown=testing:testing requirements-*.txt /home/testing/gmxapi/
56
57 RUN . $VENV/bin/activate && \
58     pip install --no-cache-dir -r /home/testing/gmxapi/requirements-test.txt
59
60 COPY --from=gromacs $CMAKE_ROOT $CMAKE_ROOT
61 COPY --from=gromacs /usr/local/gromacs /usr/local/gromacs
62
63 ADD --chown=testing:testing src /home/testing/gmxapi/src
64 ADD --chown=testing:testing src/gmxapi /home/testing/gmxapi/src/gmxapi
65
66 RUN . $VENV/bin/activate && \
67     . /usr/local/gromacs/bin/GMXRC && \
68     (cd $HOME/gmxapi/src && \
69      pip install --no-cache-dir . \
70     )
71
72 ADD --chown=testing:testing src/test /home/testing/gmxapi/test
73 ADD scripts /docker_entry_points
74 ADD --chown=testing:testing test /home/testing/test
75
76 ADD --chown=testing:testing sample_restraint /home/testing/sample_restraint
77
78 # TODO: (#3027) Get googletest sources locally.
79 RUN . $VENV/bin/activate && \
80     . /usr/local/gromacs/bin/GMXRC && \
81     (cd $HOME/sample_restraint && \
82      mkdir build && \
83      cd build && \
84      cmake .. \
85              -DDOWNLOAD_GOOGLETEST=ON \
86              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON && \
87      make -j4 && \
88      make test && \
89      make install \
90     )
91
92 # TODO: this can be in the root user section above once it is stable
93 COPY docker/entrypoint.sh /
94
95 ENTRYPOINT ["/entrypoint.sh"]
96 CMD ["run_full"]
97
98
99 # MPI tests can be run in this container without requiring MPI on the host.
100 # (We suggest running your docker engine with multiple CPU cores allocated.)
101 #     docker run --rm -t gmxapi/ci:${REF} /home/testing/scripts/run_full_mpi.sh
102 # We should also try tests with an MPI-connected set of docker containers.
103
104 # To be able to step through with gdb, run with something like the following, replacing
105 # 'imagename' with the name of the docker image built with this recipe.
106 # docker run --rm -ti --security-opt seccomp=unconfined imagename bash