5832f3e28c337fbcc9a2751d1d7ba23a7d2a62db
[alexxy/gromacs.git] / python_packaging / docker / gromacs.dockerfile
1 # Provide an easy-to-reproduce environment in which to test full Python functionality.
2 # Produce an image with GROMACS installed. Use the root of the repository as the build context
3
4 # Optionally, set `--build-arg DOCKER_CORES=N` for a Docker engine running with access to more than 1 CPU.
5 #    REF=`git show -s --pretty=format:"%h"`
6 #    docker build -t gmxapi/gromacs-${MPIFLAVOR}:${REF} \
7 #               --build-arg DOCKER_CORES=4 \
8 #               --build-arg MPIFLAVOR=${MPIFLAVOR} \
9 #               -f gromacs.dockerfile ../..
10
11 # This image serves as a base for integration with the gmxapi Python tools and sample code.
12
13 ARG MPIFLAVOR=mpich
14 ARG REF=latest
15 FROM gmxapi/gromacs-dependencies-$MPIFLAVOR:$REF as build
16
17 ENV SRC_DIR /tmp/gromacs-source
18 COPY . $SRC_DIR
19
20 ENV BUILD_DIR /tmp/gromacs-build
21 RUN mkdir -p $BUILD_DIR
22 WORKDIR $BUILD_DIR
23
24 ARG DOCKER_CORES=1
25 # Allow the build type to be specified with `docker build --build-arg TYPE=something`
26 ARG TYPE=Release
27 RUN cmake $SRC_DIR \
28         -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs \
29         -DGMXAPI=ON \
30         -DGMX_THREAD_MPI=ON \
31         -DGMX_BUILD_HELP=OFF \
32         -DGMX_USE_RDTSCP=OFF \
33         -DGMX_REQUIRE_VALID_TOOLCHAIN=TRUE \
34         -DGMX_INSTALL_LEGACY_API=ON \
35         -DCMAKE_BUILD_TYPE=$TYPE
36 RUN make -j$DOCKER_CORES
37 RUN make -j$DOCKER_CORES tests
38 RUN make -j$DOCKER_CORES install
39
40 FROM gmxapi/gromacs-dependencies-$MPIFLAVOR:$REF
41
42 COPY --from=build /usr/local/gromacs /usr/local/gromacs