Merge branch 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 # We use "--no-cache-dir" to reduce Docker image size. The other pip flags are
67 # to eliminate network access and speed up the build, since we already know we
68 # have installed the dependencies.
69 RUN . $VENV/bin/activate && \
70     (cd $HOME/gmxapi/src && \
71      GMXTOOLCHAINDIR=/usr/local/gromacs/share/cmake/gromacs \
72       pip install --no-cache-dir --no-deps --no-index --no-build-isolation . \
73     )
74
75 ADD --chown=testing:testing src/test /home/testing/gmxapi/test
76 ADD scripts /docker_entry_points
77 ADD --chown=testing:testing test /home/testing/test
78
79 ADD --chown=testing:testing sample_restraint /home/testing/sample_restraint
80
81 # TODO: (#3027) Get googletest sources locally.
82 RUN . $VENV/bin/activate && \
83     . /usr/local/gromacs/bin/GMXRC && \
84     (cd $HOME/sample_restraint && \
85      mkdir build && \
86      cd build && \
87      cmake .. \
88              -DDOWNLOAD_GOOGLETEST=ON \
89              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON && \
90      make -j4 && \
91      make test && \
92      make install \
93     )
94
95 # TODO: this can be in the root user section above once it is stable
96 COPY docker/entrypoint.sh /
97
98 ENTRYPOINT ["/entrypoint.sh"]
99 CMD ["run_full"]
100
101
102 # MPI tests can be run in this container without requiring MPI on the host.
103 # (We suggest running your docker engine with multiple CPU cores allocated.)
104 #     docker run --rm -t gmxapi/ci:${REF} /home/testing/scripts/run_full_mpi.sh
105 # We should also try tests with an MPI-connected set of docker containers.
106
107 # To be able to step through with gdb, run with something like the following, replacing
108 # 'imagename' with the name of the docker image built with this recipe.
109 # docker run --rm -ti --security-opt seccomp=unconfined imagename bash