-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·163 lines (128 loc) · 5.8 KB
/
Dockerfile
File metadata and controls
executable file
·163 lines (128 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# VASP with GNU compilers + openmpi + scalapack + hdf5 + libxc + miniconda python3 with py4vasp
# This Dockerfile asumes you have an entrypoint.sh script and makefile.include in the same directory
# and a subdirectory /vasp which contains either vasp.6.4.3.tgz or vasp.6.4.3+vtsttools.tgz
# as well as potpaw_PBE.64.tgz and vdw_kernel.bindat.tgz archives
# When running the container it is recommended to bind the container /tmp directory
# to your work directory (usually /scratch, /tmp or /home/YOUR_USER/whichever/directory/you/like)
FROM ubuntu:22.04
# change shell to bash (not neccessary but useful)
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
LABEL org.opencontainers.image.authors="Dr. Neven Golenić <neven.golenic@gmail.com>"
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Set default number of OpenMP threads
ENV OMP_NUM_THREADS=1
# Discourage apt from trying to talk to you
ARG DEBIAN_FRONTEND=noninteractive
# Copy default entryppint bash script and ensure it is executable
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Install build dependencies
RUN apt-get update -y && \
apt-get install -y --no-install-recommends apt-utils make rsync patch htop wget nano vim less git ca-certificates && \
apt-get install -y --no-install-recommends g++ gfortran\
libopenblas-dev \
libscalapack-mpi-dev \
openssh-server \
libopenmpi-dev openmpi-common openmpi-bin \
libfftw3-dev \
autoconf automake libtool m4
# apt-get cleanup
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
# Build HDF5
WORKDIR /opt
RUN wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.gz && \
tar -xvzf hdf5-1.12.2.tar.gz && \
cd hdf5-1.12.2 && \
./configure --prefix=/opt/hdf5 --enable-fortran && \
make -j$(nproc --all) && \
make install && \
cd .. && \
rm -rf hdf5-1.12.2 hdf5-1.12.2.tar.gz
ENV PATH="/opt/hdf5/bin:$PATH"
ENV LD_LIBRARY_PATH="/opt/hdf5/lib:$LD_LIBRARY_PATH"
# Build libxc
WORKDIR /opt
RUN git clone -b 7.0.0 https://gitlab.com/libxc/libxc.git libxc.7.0.0
WORKDIR /opt/libxc.7.0.0
RUN aclocal
RUN libtoolize
# RUN autoconf -i
RUN autoreconf -fi
RUN mkdir -p libxc
RUN ./configure --prefix=/opt/libxc.7.0.0 --disable-fhc CC=gcc FC=mpifort
RUN make -j$(nproc --all)
# RUN make check # commented out as it resuls in failed build; unit-tests fail when compiling with the --disable-fhc flag
RUN make install
ENV PATH="$PATH:/opt/libxc.7.0.0/bin"
# Build VASP
WORKDIR /opt
# Comment out line below if you need VTST tools
# ADD ./vasp/vasp.6.4.3.tgz .
# Uncomment line below if you need VTST tools (v 2.04)
ADD ./vasp/vasp.6.4.3+vtsttools.tgz .
RUN mv vasp.6.4.3+vtsttools vasp.6.4.3
WORKDIR vasp.6.4.3
# RUN cp arch/makefile.include.gnu_omp makefile.include
COPY ./makefile.include .
RUN make DEPS=1 -j$(nproc --all) std
# Export VASP to path
ENV PATH="$PATH:/opt/vasp.6.4.3/bin/"
# Copy pseudopotential files and vdW kernel to /tmp
WORKDIR /tmp
RUN mkdir -p pseudo
ADD ./vasp/potpaw_PBE.64.tgz ./pseudo
ADD ./vasp/vdw_kernel.bindat.tgz .
# Add non root user
RUN useradd -ms /bin/bash vasp
RUN chown vasp:vasp /tmp
# Install Miniconda in /opt/miniconda3
WORKDIR /opt
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; \
elif [ "$ARCH" = "aarch64" ]; then \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O miniconda.sh; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
bash miniconda.sh -b -p /opt/miniconda3 && \
rm miniconda.sh
# Change ownership of Miniconda directory to vasp
RUN chown -R vasp:vasp /opt/miniconda3
# Change to non-root user
USER vasp
# Ensure .custom_bashrc exists
RUN touch ~/.custom_bashrc
# Add Miniconda to PATH and configure .bashrc
ENV PATH="/opt/miniconda3/bin:$PATH"
# Set up .bashrc
RUN echo "export PATH=/opt/miniconda3/bin:\$PATH" >> ~/.custom_bashrc && \
echo "source /opt/miniconda3/etc/profile.d/conda.sh" >> ~/.custom_bashrc && \
cat "/opt/miniconda3/etc/profile.d/conda.sh" >> ~/.custom_bashrc && \
echo "conda activate base" >> ~/.custom_bashrc
# Ensure .custom_bashrc is sourced so that conda commands below work
RUN source ~/.custom_bashrc
# # Ensure this is sourced in every shell session
# RUN echo "source .custom_bashrc" >> ~/.bashrc
WORKDIR /opt/miniconda3/bin
# Install Python packages
RUN ./conda init bash && \
./conda install -y -c conda-forge numpy matplotlib scipy jupyter py4vasp && \
./conda clean -afy
# removed pylibxc=7.0.0 from conda (takes up more space and is not connected to the compiled (above) libxc version)
WORKDIR /opt/miniconda3
# Clean up unnecessary files from Miniconda
RUN find ./ -follow -type f -name '*.a' -delete && \
find ./ -follow -type f -name '*.js.map' -delete
# Add alias for a quick vasp run (local)
RUN echo "alias vs=\"mpirun -np $(nproc --all) vasp_std\"" >> ~/.custom_bashrc
RUN echo "alias vasp_rm=\"rm -f CHG CHGCAR CONTCAR STOPCAR DOSCAR DYNMAT EIGENVAL IBZKPT OPTIC OSZICAR OUTCAR PROCAR PCDAT WAVECAR XDATCAR PARCHG vasprun.xml REPORT wannier90.win wannier90_band.gnu wannier90_band.kpt wannier90.chk wannier90.wout vaspout.h5 PENALTYPOT HILLSPOT ML_LOGFILE ML_ABN ML_FFN ML_HIS ML_REG\"" >> ~/.custom_bashrc
# Set up default mount point (for Docker only, Singularity handles this differently)
VOLUME /tmp
WORKDIR /tmp
# In case one wants to use the container dirrectly "akin to" a vasp binary
# CMD ["mpirun", "-np $(nproc --all)", "--mca", "btl_vader_single_copy_mechanism", "none", "/opt/vasp.6.4.3/bin/vasp_std"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Not needed since we have an entrypoint, but useful as a fallback
CMD ["/bin/bash"]