Skip to content

Commit 4019bd5

Browse files
committed
replace sources
1 parent 686a481 commit 4019bd5

2 files changed

Lines changed: 110 additions & 78 deletions

File tree

Dockerfile

Lines changed: 65 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
1+
# Define the build argument
2+
ARG CHINA=False
3+
14
# 1. Define the base image
25
FROM ubuntu:22.04 AS base
36

7+
# Define the build argument for conditional logic
8+
ARG CHINA
9+
10+
# Use shell logic to set the ENV variable based on the build argument
11+
RUN if [ "$CHINA" = "True" ]; then \
12+
echo "Setting IS_CHINA_ENV=True"; \
13+
echo "export IS_CHINA_ENV=True" >> /tmp/bashrc; \
14+
echo "export RootUrl=https://github.com/RESTGroup" >> /tmp/bashrc; \
15+
echo "export RootUrle=https://gitee.com/RESTGroup" >> /tmp/bashrc; \
16+
else \
17+
echo "Setting IS_CHINA_ENV=False"; \
18+
echo "export IS_CHINA_ENV=False" >> /tmp/bashrc; \
19+
echo "export RootUrl=https://gitee.com/RESTGroup" >> /tmp/bashrc; \
20+
echo "export RootUrle=https://gitee.com/RESTGroup" >> /tmp/bashrc; \
21+
fi
22+
423
# Prevent interactive prompts during installation
524
ENV DEBIAN_FRONTEND=noninteractive
625

7-
# Define whether the environment is inside China and GitHub URL
8-
ENV IS_CHINA_ENV=False
9-
ENV GITHUB=github.com
10-
1126
# Set compilers for C, C++, and Fortran
1227
ENV CC=gcc
1328
ENV CXX=g++
1429
ENV FC=gfortran
1530

16-
# Define repository URL for dependencies
17-
ENV resturl=https://${GITHUB}/RESTGroup
18-
1931
# Set the working directory for subsequent commands
2032
WORKDIR /opt
2133

2234
# Configure system package sources for faster access if inside China
23-
RUN if [ "$IS_CHINA_ENV" = "True" ]; then \
35+
RUN . /tmp/bashrc \
36+
&& if [ "$IS_CHINA_ENV" = "True" ]; then \
2437
sed -i -e 's|http://archive.ubuntu.com/ubuntu/|http://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' \
2538
-e 's|http://security.ubuntu.com/ubuntu/|http://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' /etc/apt/sources.list; \
2639
fi
@@ -64,7 +77,8 @@ RUN git config --global http.postBuffer 524288000 \
6477
&& git config --global http.lowSpeedTime 999999
6578

6679
# Configure pip index URL for China mirrors if applicable
67-
RUN if [ "$IS_CHINA_ENV" = "True" ]; then \
80+
RUN . /tmp/bashrc \
81+
&& if [ "$IS_CHINA_ENV" = "True" ]; then \
6882
export PIP_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple; \
6983
fi
7084

@@ -74,14 +88,16 @@ ENV RUSTUP_HOME=/opt/.rustup
7488
ENV PATH="/opt/.cargo/bin:$PATH"
7589

7690
# Install Rust programming language
77-
RUN if [ "$IS_CHINA_ENV" = "True" ]; then \
91+
RUN . /tmp/bashrc \
92+
&& if [ "$IS_CHINA_ENV" = "True" ]; then \
7893
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static; \
7994
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup; \
8095
fi && \
8196
curl https://sh.rustup.rs -sSf | sh -s -- -y
8297

8398
# Configure Cargo to use China mirrors
84-
RUN if [ "$IS_CHINA_ENV" = "True" ]; then \
99+
RUN . /tmp/bashrc \
100+
&& if [ "$IS_CHINA_ENV" = "True" ]; then \
85101
mkdir -p /opt/.cargo && \
86102
echo "\
87103
[source.crates-io] \n\
@@ -97,7 +113,8 @@ registry = 'https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git' \n\
97113
RUN rustc --version && cargo --version
98114

99115
# Clone the workspace repository and configure environment paths
100-
RUN git clone --depth=1 ${resturl}/rest_workspace.git \
116+
RUN . /tmp/bashrc \
117+
&& git clone --depth=1 ${RootUrl}/rest_workspace.git \
101118
&& cd rest_workspace \
102119
&& git fetch --depth=1 origin 633e4151499fdfa6b301fe8741204d5dc2892494 \
103120
&& git checkout 633e4151499fdfa6b301fe8741204d5dc2892494 \
@@ -114,37 +131,36 @@ FROM base AS dependencies
114131
ENV OMP_NUM_THREADS=4
115132

116133
# Build and install OpenBLAS library
117-
# RUN git clone https://${GITHUB}/OpenMathLib/OpenBLAS.git -b v0.3.28 OpenBLAS \
118-
RUN wget https://${GITHUB}/OpenMathLib/OpenBLAS/archive/refs/tags/v0.3.28.tar.gz \
119-
&& tar xf v0.3.28.tar.gz && rm v0.3.28.tar.gz && mv OpenBLAS-0.3.28 OpenBLAS \
134+
RUN . /tmp/bashrc \
135+
&& git clone --depth=1 ${RootUrl}/OpenBLAS.git -b v0.3.28 OpenBLAS \
120136
&& cd OpenBLAS \
121137
&& make DYNAMIC_ARCH=1 TARGET=HASWELL USE_OPENMP=1 \
122138
&& cp libopenblas.so* $REST_EXT_DIR/
123139

124140
# Build and install libcint library
125-
# RUN git clone https://${GITHUB}/sunqm/libcint.git -b v6.1.2 libcint \
126-
RUN wget https://${GITHUB}/sunqm/libcint/archive/refs/tags/v6.1.2.tar.gz \
127-
&& tar xf v6.1.2.tar.gz && rm v6.1.2.tar.gz && mv libcint-6.1.2 libcint \
141+
RUN . /tmp/bashrc \
142+
&& git clone --depth=1 ${RootUrl}/libcint.git -b v6.1.2 libcint \
128143
&& cd libcint \
129144
&& mkdir build && cd build \
130145
&& cmake -DWITH_RANGE_COULOMB=1 .. \
131146
&& make -j32 \
132147
&& cp libcint.so* $REST_EXT_DIR/
133148

134149
# Build and install libxc library
135-
RUN wget https://gitlab.com/libxc/libxc/-/archive/7.0.0/libxc-7.0.0.tar.gz \
136-
&& tar xf libxc-* && rm libxc-*.tar.gz \
137-
&& cd libxc-* \
150+
RUN . /tmp/bashrc \
151+
&& git clone --depth=1 ${RootUrle}/libxc.git -b 7.0.0 libxc \
152+
&& cd libxc \
138153
&& autoreconf -i \
139154
&& ./configure --prefix=$(pwd) --enable-shared \
140155
&& make -j32 && make install \
141156
&& cp lib/libxc.so* $REST_EXT_DIR/ \
142157
&& cp lib/libxc.a $REST_EXT_DIR/
143158

159+
144160
# Build and install HDF5 library
145-
RUN wget https://${GITHUB}/HDFGroup/hdf5/releases/download/hdf5_1.14.5/hdf5-1.14.5.tar.gz \
146-
&& tar xf hdf5-*.tar.gz && rm hdf5-*.tar.gz \
147-
&& cd hdf5-* \
161+
RUN . /tmp/bashrc \
162+
&& git clone --depth=1 ${RootUrl}/hdf5.git -b hdf5_1.14.5 hdf5_src \
163+
&& cd hdf5_src \
148164
&& ./configure --prefix=/opt/hdf5 \
149165
&& make -j32 && make -j32 install \
150166
&& cd /opt/hdf5 \
@@ -153,21 +169,25 @@ RUN wget https://${GITHUB}/HDFGroup/hdf5/releases/download/hdf5_1.14.5/hdf5-1.14
153169

154170
# Build REST-specific dependencies like librest2fch and DFT libraries
155171
# Install librest2fch for converting quantum chemistry formats
156-
RUN git clone --depth=1 https://gitlab.com/jeanwsr/MOKIT -b for-rest \
172+
RUN . /tmp/bashrc \
173+
&& git clone --depth=1 ${RootUrle}/MOKIT.git -b for-rest MOKIT \
157174
&& cd MOKIT/src \
158175
&& git fetch --depth=1 origin 225f55756784a0539f7ef34f97221927df84136d \
159176
&& git checkout 225f55756784a0539f7ef34f97221927df84136d \
160177
&& make rest2fch -f Makefile.gnu_openblas \
161178
&& cp ../mokit/lib/librest2fch.so $REST_EXT_DIR/
162179

163180
# Install ninja
164-
RUN wget https://${GITHUB}/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip \
165-
&& unzip ninja-linux.zip \
166-
&& mv ninja /usr/local/bin/ \
167-
&& rm ninja-linux.zip
181+
RUN . /tmp/bashrc \
182+
&& git clone --depth=1 ${RootUrl}/ninja.git -b v1.12.1 ninja \
183+
&& cd ninja \
184+
&& cmake -Bbuild-cmake \
185+
&& cmake --build build-cmake \
186+
&& mv build-cmake/ninja /usr/local/bin/
168187

169188
# Install dftd3 (Dispersion Correction)
170-
RUN git clone --depth=1 https://${GITHUB}/dftd3/simple-dftd3.git -b v1.2.1 \
189+
RUN . /tmp/bashrc \
190+
&& git clone --depth=1 ${RootUrl}/simple-dftd3.git -b v1.2.1 \
171191
&& cd simple-dftd3 \
172192
&& cmake -B build -G Ninja -DBUILD_SHARED_LIBS=1 \
173193
&& cmake --build build \
@@ -177,7 +197,8 @@ RUN git clone --depth=1 https://${GITHUB}/dftd3/simple-dftd3.git -b v1.2.1 \
177197
&& cd $REST_EXT_DIR && ln -s libs-dftd3.so.1 libs-dftd3.so
178198

179199
# Build dftd4 for advanced dispersion correction
180-
RUN git clone --depth=1 https://${GITHUB}/dftd4/dftd4.git -b v3.7.0 \
200+
RUN . /tmp/bashrc \
201+
&& git clone --depth=1 ${RootUrl}/dftd4.git -b v3.7.0 \
181202
&& cd dftd4 \
182203
&& cmake -B build -G Ninja -DBUILD_SHARED_LIBS=1 \
183204
&& cmake --build build \
@@ -195,29 +216,33 @@ COPY --from=dependencies $REST_EXT_DIR/ $REST_EXT_DIR/
195216
COPY --from=dependencies $REST_EXT_INC/ $REST_EXT_INC/
196217

197218
# Clone and build REST software components
198-
RUN cd rest_workspace\
199-
&& git clone --depth=1 ${resturl}/rest.git rest \
219+
RUN . /tmp/bashrc \
220+
&& cd rest_workspace\
221+
&& git clone --depth=1 ${RootUrl}/rest.git rest \
200222
&& cd rest \
201223
&& git fetch --depth=1 origin 783158e5d6dc24edb0d7b6cbf7a4a8816c568403 \
202224
&& git checkout 783158e5d6dc24edb0d7b6cbf7a4a8816c568403
203225

204-
RUN cd rest_workspace\
205-
&& git clone --depth=1 ${resturl}/rest_tensors.git rest_tensors \
226+
RUN . /tmp/bashrc \
227+
&& cd rest_workspace\
228+
&& git clone --depth=1 ${RootUrl}/rest_tensors.git rest_tensors \
206229
&& cd rest_tensors \
207230
&& git fetch --depth=1 origin 69862164277843a3c3faccb596f62840e60ad6ae \
208231
&& git checkout 69862164277843a3c3faccb596f62840e60ad6ae
209-
RUN cd rest_workspace\
210-
&& git clone --depth=1 ${resturl}/rest_libcint.git rest_libcint \
232+
RUN . /tmp/bashrc \
233+
&& cd rest_workspace\
234+
&& git clone --depth=1 ${RootUrl}/rest_libcint.git rest_libcint \
211235
&& cd rest_libcint \
212236
&& git fetch --depth=1 origin 017c38b248077eb6d24413166a126e0fcfdbec9d \
213237
&& git checkout 017c38b248077eb6d24413166a126e0fcfdbec9d
214-
RUN cd rest_workspace\
215-
&& git clone --depth=1 ${resturl}/rest_regression.git rest_regression \
238+
RUN . /tmp/bashrc \
239+
&& cd rest_workspace\
240+
&& git clone --depth=1 ${RootUrl}/rest_regression.git rest_regression \
216241
&& cd rest_regression \
217242
&& git fetch --depth=1 origin c45e5d8c3d2d8ff6c76977e45425aaf5c07012bd \
218243
&& git checkout c45e5d8c3d2d8ff6c76977e45425aaf5c07012bd
219244

220-
# # Build and verify REST
245+
# Build and verify REST
221246
RUN cd rest_workspace \
222247
&& ./Config -r github -f $FC -e
223248

README.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,97 @@
11
# REST Docker
22

3-
## Get Image
3+
## Getting the Docker Image
44

5-
You can get the Docker image or build the Docker image yourself.
5+
You can either pull the Docker image from Docker Hub or build it yourself.
66

77
### Pull from Docker Hub
88

9-
The URL is [Docker Hub - bsplu/rest_docker](https://hub.docker.com/r/bsplu/rest_docker).
10-
119
To pull the image from Docker Hub, follow these steps:
1210

1311
1. Open your terminal.
14-
2. Run the following command to pull the image:
12+
2. Run the following command:
1513
```sh
1614
docker pull bsplu/rest_docker
1715
```
18-
3. To verify that the image has been pulled, run:
16+
3. Verify the image has been pulled by running:
1917
```sh
2018
docker images
2119
```
22-
This command will list all the Docker images on your system.
2320

24-
### Build Docker Image Yourself
21+
### Build the Docker Image
2522

2623
To build the Docker image yourself, follow these steps:
2724

2825
1. Open your terminal.
2926
2. Navigate to the directory containing the Dockerfile.
30-
3. Run the following command to build the image:
27+
3. Run the following command:
28+
```sh
29+
docker build -t [name]:[version] .
30+
```
31+
4. Verify the images after a successful build:
32+
```sh
33+
docker images
34+
```
35+
5. [Optional] After you build, you may want to clean the cache:
3136
```sh
32-
docker build -t rest/[environment_specific]:v[version] . -f Dockerfile
37+
docker image prune -f
3338
```
34-
This command will create a Docker image with the tag `rest/[environment_specific]:v[version]`.
3539

36-
## Run
40+
**Note:**
41+
- `[name]` is the image name you want to use, like `rest/mpi`, `your_name/rest/x86`, etc.
42+
- `[version]` is the version tag for the named image, like `v0.2`, etc.
43+
- If you are in China, you may want to use `docker build --build-arg CHINA=True -t [name]:[version] .` to speed up downloading files.
3744

38-
### Shell Mode (for debugging)
45+
## Running the Docker Container
3946

40-
To run the container in interactive mode (useful for debugging), follow these steps:
47+
### Shell Mode (for Debugging)
48+
49+
To run the container in interactive mode:
4150

4251
1. Open your terminal.
4352
2. Run the following command:
4453
```sh
45-
docker run --rm -it rest/[environment_specific]:v[version] /bin/bash
54+
docker run --rm -it [name]:[version] /bin/bash
4655
```
47-
3. Inside the container, you can run your commands as needed.
48-
4. When you are done, type `exit` to leave the container. The container will be cleaned up automatically.
56+
3. When done, type `exit` to leave the container.
4957

50-
### Exec Mode (for job submission)
58+
### Exec Mode (for Job Submission)
5159

52-
To run the container for job submission, follow these steps:
60+
To run the container for job submission:
5361

5462
1. Open your terminal.
55-
2. Mount a local directory to the container and set the working directory by running:
63+
2. Run the following command:
5664
```sh
57-
docker run --rm -v /path/to/local/dir:/path/in/container -w /path/in/container rest/[environment_specific]:v[version] /bin/bash -c "rest"
65+
docker run --rm -v /path/to/local/dir:/path/in/container -w /path/in/container [name]:[version] /bin/bash -c "rest"
5866
```
59-
Replace `/path/to/local/dir` with the path to your local directory and `/path/in/container` with the desired path inside the container.
60-
3. The command `rest` will be executed inside the container with the specified working directory.
61-
4. When the job is done, the container will exit and be cleaned up automatically.
62-
63-
## Convert to Singularity
6467

65-
To convert the Docker image to a Singularity image, follow one of the two methods below:
68+
## Converting to Singularity
6669

67-
### Option 1: Using docker-daemon
70+
### Using docker-daemon
6871

6972
Run the following command:
7073
```sh
71-
singularity build rest_[environment_specific]_v[version].sif docker-daemon://rest/[environment_specific]:v[version]
74+
singularity build [name]_[version].sif docker-daemon://[name]:[version]
7275
```
7376

74-
### Option 2: Export Docker Image to a TAR file
77+
### Export Docker Image to a TAR File
7578

76-
1. Export the Docker image to a TAR file:
79+
1. Export the Docker image:
7780
```sh
78-
docker save -o rest_[environment_specific]_v[version].tar rest/[environment_specific]:v[version]
81+
docker save -o [name]_[version].tar [name]:[version]
7982
```
80-
2. Build the Singularity image from the TAR file:
83+
2. Build the Singularity image:
8184
```sh
82-
singularity build rest_[environment_specific]_v[version].sif docker-archive://rest_[environment_specific]_v[version].tar
85+
singularity build [name]_[version].sif docker-archive://[name]_[version].tar
8386
```
8487

85-
### Run the Singularity Container
88+
### Running the Singularity Container
8689

87-
Once the Singularity image is built, you can run it with:
90+
To run the Singularity container:
8891
```sh
89-
singularity exec --bind /path/to/local:/path/in/container rest_[environment_specific]_v[version].sif bash -c "rest"
90-
```
92+
singularity exec --bind /path/to/local:/path/in/container [name]_[version].sif bash -c "rest"
93+
```
94+
95+
## For Developers
96+
97+
Use the `dev` branch for development. In this branch, the `admin` user is not created, and root is the default user. This image can be used as a base layer for your own Docker images or for development and compilation. For production use, ensure you create an `admin` user for security and ease of running commands like `mpirun`.

0 commit comments

Comments
 (0)