Require pybind 2.6 from environment for gmxapi Python package extension module.
[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 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 ARG REF=latest
23
24 FROM gmxapi/gromacs-dependencies-mpich as python-base
25
26 RUN apt-get update && \
27     apt-get -yq --no-install-suggests --no-install-recommends install \
28         python3 \
29         python3-dev \
30         python3-venv && \
31     rm -rf /var/lib/apt/lists/*
32
33 # TODO: Use non-system Python installations for explicit version coverage.
34 # Consider pyenv for generic management of Python environment.
35
36 RUN groupadd -r testing && useradd -m -s /bin/bash -g testing testing
37
38 USER testing
39
40 ENV VENV /home/testing/venv
41 RUN python3 -m venv $VENV
42 RUN . $VENV/bin/activate && \
43     pip install --no-cache-dir --upgrade pip setuptools wheel
44
45 ADD --chown=testing:testing requirements-*.txt /home/testing/gmxapi/
46
47 #
48 # Use gromacs installation from gmxapi/gromacs image
49 #
50
51 FROM gmxapi/gromacs-mpich:$REF as gromacs
52 # This intermediate is necessary because the COPY command does not support syntax like the following:
53 #COPY --from=gmxapi/gromacs:$REF /usr/local/gromacs /usr/local/gromacs
54
55 FROM python-base
56
57 COPY --from=gromacs /usr/local/gromacs /usr/local/gromacs
58
59 RUN $VENV/bin/python -m pip install --upgrade pip setuptools wheel
60 RUN $VENV/bin/python -m pip install --no-cache-dir --no-build-isolation -r /home/testing/gmxapi/requirements-test.txt
61
62 ADD --chown=testing:testing src /home/testing/gmxapi/src
63 ADD --chown=testing:testing src/gmxapi /home/testing/gmxapi/src/gmxapi
64
65 # We use "--no-cache-dir" to reduce Docker image size.
66 RUN . $VENV/bin/activate && \
67     (cd $HOME/gmxapi/src && \
68      rm -rf build dist && \
69      GMXTOOLCHAINDIR=/usr/local/gromacs/share/cmake/gromacs \
70       pip install --no-cache-dir --verbose . \
71     )
72
73 ADD --chown=testing:testing src/test /home/testing/gmxapi/test
74 ADD scripts /docker_entry_points
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              -DPYTHON_EXECUTABLE=$VENV/bin/python \
86              -DDOWNLOAD_GOOGLETEST=ON \
87              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON && \
88      make -j4 && \
89      make tests && \
90      make test && \
91      make install \
92     )
93
94 # TODO: this can be in the root user section above once it is stable
95 COPY docker/entrypoint.sh /
96
97 ENTRYPOINT ["/entrypoint.sh"]
98 CMD ["run_full"]
99
100
101 # MPI tests can be run in this container without requiring MPI on the host.
102 # (We suggest running your docker engine with multiple CPU cores allocated.)
103 #     docker run --rm -t gmxapi/ci:${REF} /home/testing/scripts/run_full_mpi.sh
104 # We should also try tests with an MPI-connected set of docker containers.
105
106 # To be able to step through with gdb, run with something like the following, replacing
107 # 'imagename' with the name of the docker image built with this recipe.
108 # docker run --rm -ti --security-opt seccomp=unconfined imagename bash