| 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 main 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 |
ARG MPIFLAVOR=mpich |
| 24 |
|
| 25 |
FROM gmxapi/gromacs-dependencies-$MPIFLAVOR as python-base |
| 26 |
|
| 27 |
RUN apt-get update && \ |
| 28 |
DEBIAN_FRONTEND=noninteractive apt-get -yq --no-install-suggests --no-install-recommends \ |
| 29 |
install \ |
| 30 |
python3 \ |
| 31 |
python3-dev \ |
| 32 |
python3-venv && \ |
| 33 |
rm -rf /var/lib/apt/lists/* |
| 34 |
|
| 35 |
# TODO: Use non-system Python installations for explicit version coverage. |
| 36 |
# Consider pyenv for generic management of Python environment. |
| 37 |
|
| 38 |
RUN groupadd -r testing && useradd -m -s /bin/bash -g testing testing |
| 39 |
|
| 40 |
USER testing |
| 41 |
|
| 42 |
ENV VENV /home/testing/venv |
| 43 |
RUN python3 -m venv $VENV |
| 44 |
RUN . $VENV/bin/activate && \ |
| 45 |
pip install --no-cache-dir --upgrade pip setuptools wheel |
| 46 |
|
| 47 |
# |
| 48 |
# Use gromacs installation from gmxapi/gromacs image |
| 49 |
# |
| 50 |
|
| 51 |
FROM gmxapi/gromacs-$MPIFLAVOR:$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 |
|
| 61 |
ADD --chown=testing:testing gmxapi /home/testing/gmxapi |
| 62 |
ADD --chown=testing:testing sample_restraint /home/testing/sample_restraint |
| 63 |
RUN $VENV/bin/python -m pip install --no-cache-dir --no-build-isolation -r /home/testing/gmxapi/requirements.txt |
| 64 |
|
| 65 |
# We use "--no-cache-dir" to reduce Docker image size. |
| 66 |
RUN . $VENV/bin/activate && \ |
| 67 |
(cd $HOME/gmxapi && \ |
| 68 |
CMAKE_ARGS="-Dgmxapi_ROOT=/usr/local/gromacs -C /usr/local/gromacs/share/cmake/gromacs/gromacs-hints.cmake" \ |
| 69 |
pip install --no-cache-dir --verbose . \ |
| 70 |
) |
| 71 |
|
| 72 |
ADD --chown=testing:testing sample_restraint /home/testing/sample_restraint |
| 73 |
|
| 74 |
# To test behavior as in GitLab CI, copy the googletest sources, export CI=1 to the cmake |
| 75 |
# configure command, and remove the option to download googletest. |
| 76 |
#COPY --from=gromacs /gromacs-source/src/external/googletest /home/testing/sample_restraint/external/googletest |
| 77 |
RUN cmake --version |
| 78 |
RUN . $VENV/bin/activate && \ |
| 79 |
. /usr/local/gromacs/bin/GMXRC && \ |
| 80 |
(cd $HOME/sample_restraint && \ |
| 81 |
mkdir build && \ |
| 82 |
cd build && \ |
| 83 |
cmake .. \ |
| 84 |
-C /usr/local/gromacs/share/cmake/gromacs/gromacs-hints.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 |
ADD --chown=testing:testing src/test /home/testing/gmxapi/test |
| 95 |
ADD scripts /docker_entry_points |
| 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 |