Skip to content

Commit cf0f4f9

Browse files
committed
Version fix, architecture support, and changes to readme
1 parent d3ab2da commit cf0f4f9

File tree

2 files changed

+39
-42
lines changed

2 files changed

+39
-42
lines changed

docker/README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,12 @@ OpenFermion (or any of its plugins) using the standard procedure.
2727

2828

2929
## Setting up Docker for the first time
30-
3130
The Dockerfile is based on the [Ubuntu image](https://hub.docker.com/_/ubuntu) (ver. 22.04).
32-
It creates a Python (ver. 3.12) virtual environemnt (named `fermion`) using Miniforge and installs all dependencies within it. Psi4 is installed with a conda [command](https://psicode.org/installs/v191/).
33-
The default configuration uses the latest Miniforge installer on Linux `aarch64` architecture.
31+
Two Linux architectures are supported in the Dockerfile: x86_64 (amd64) and aarch64 (arm64).
32+
Detecting your host's architecture is handled automatically through the following docker image building process, so you don't have to check it manually.
33+
It creates a Python (ver. 3.12) virtual environment (named `fermion`) using Miniforge and installs all dependencies within it. Psi4 is installed with a [conda command](https://psicode.org/installs/v191/).
3434

35-
### Customizing the Environment
36-
You can manually edit the Dockerfile if you need to set up a different development environment (e.g., changing the Ubuntu, Python, Miniforge, or Psi4 version).
37-
38-
If your local machine builds Linux `x86_64` architecture with the Dockerfile, the `wget` command
39-
for the Miniforge installer (Line 40 in the Dockerfile)
40-
```
41-
wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh"
42-
```
43-
must be changed to
44-
```
45-
wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh"
46-
```
47-
You can check other Miniforge installers [here](https://github.com/conda-forge/miniforge?tab=readme-ov-file#requirements-and-installers).
35+
You can manually edit the Dockerfile if you need to set up a different development environment (e.g., changing the versions of Ubuntu, Python, Miniforge, Psi4, etc.).
4836

4937
### Building Docker Image
5038
You first need to install [Docker](https://www.docker.com/).
@@ -54,27 +42,38 @@ Dockerfile for building the OpenFermion image (/docker/dockerfile) and run
5442
```
5543
docker build -t openfermion_docker .
5644
```
57-
5845
where "openfermion_docker" is just an arbitrary name for our docker image.
5946
Building the Dockerfile starts from a base image of Ubuntu and then installs
6047
OpenFermion, its plugins, and the necessary applications needed for running these
6148
programs. This is a fairly involved setup and will take some time
62-
(perhaps up to thirty minutes depending on the computer) and disk space (several gigabytes).
49+
(perhaps up to thirty minutes, depending on the computer) and disk space (several gigabytes).
50+
51+
Line 18 in the Dockerfile
52+
```
53+
COPY . /root/workspace
54+
```
55+
copy the files in the current local directory (where the Dockerfile is located) when the image is built.
56+
If you don't want to copy the files, delete the line first and then build the image.
6357

6458
### Running the Container
6559
Once the image has been built, run the image with
6660
```
6761
docker run -it --name openfermion_container -v $(pwd):/root/workspace openfermion_docker
6862
```
69-
where "openfermion_container" is an arbitrary choice for the name of our docker container. This command will mount your current local directory to `/root/workspace` inside the running container.
63+
where "openfermion_container" is an arbitrary choice for the name of our docker container. This command will mount your current local directory, where the Dockerfile is located, to `/root/workspace` inside the running container.
7064
By default, the virtual environment `fermion` is automatically activated in the running container.
71-
After installing the `Dev Containers` extension in Visual Studio Code,
72-
you can open the container with the following option:
65+
66+
If you don't want to mount the current directory, run the following command instead:
7367
```
74-
Command Palette -> Dev Containers: Attach to Running Container..
68+
docker run -it --name openfermion_container openfermion_docker
7569
```
76-
and select `openfermion_container` for this example.
7770

71+
### Copy Local Files into the Container
72+
Line 18 in the Dockerfile (`COPY . /root/workspace`) copies the current files only once when the image is built.
73+
Local files in any directories can be copied using:
74+
```
75+
docker cp [path to file on disk] [container name]:[path in container]
76+
```
7877
An alternative way of loading files onto the Docker container is through
7978
remote repos such as GitHub. Git is installed in the Docker image.
8079
After `docker run`, one could run "git clone ..." etc to pull files

docker/dockerfile

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
FROM ubuntu:22.04
1616

17-
USER root
18-
1917
WORKDIR /root/workspace
2018
COPY . /root/workspace
2119

@@ -25,32 +23,32 @@ ENV PATH="/root/conda/bin:${PATH}"
2523
ENV PYTHONPATH=/root/pyscf
2624

2725
RUN apt-get update && \
28-
apt-get install -y build-essential \
29-
bzip2 \
30-
cmake \
31-
git \
32-
wget \
33-
libblas-dev \
34-
liblapack-dev \
35-
curl
26+
apt-get install -y --no-install-recommends bzip2=1.0.8-5build1 \
27+
cmake=3.22.1-1ubuntu1.22.04.2 \
28+
git=1:2.34.1-1ubuntu1.15 \
29+
wget=1.21.2-2ubuntu1.1 \
30+
libblas-dev=3.10.0-2ubuntu1 \
31+
liblapack-dev=3.10.0-2ubuntu1 \
32+
# in order to verify github's certificate
33+
ca-certificates=20240203~22.04.1 \
34+
build-essential=12.9ubuntu3
3635

3736
# Install miniforge https://github.com/conda-forge/miniforge?tab=readme-ov-file#as-part-of-a-ci-pipeline
38-
RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh" && \
37+
RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/download/25.3.1-0/Miniforge3-25.3.1-0-$(uname)-$(uname -m).sh" && \
3938
bash Miniforge3.sh -b -p "${HOME}/conda" && \
4039
conda init bash && \
4140
conda update -n base -c conda-forge conda && \
4241
# Create virtual env (fermion) with installing Psi4
4342
conda create -n fermion psi4 python=3.12 -c conda-forge -y && \
4443
conda install -n fermion pip -y && \
4544
# Install OpenFermion, Cirq, and plugins
46-
conda run -n fermion pip install openfermion \ cirq \ openfermioncirq \ openfermionpsi4 \ openfermionpyscf && \
47-
# Install PySCF
48-
cd /root && \
49-
git clone https://github.com/sunqm/pyscf && \
50-
cd /root/pyscf/pyscf/lib && \
51-
mkdir build && \
52-
cd build && \
53-
cmake .. && \
45+
conda run -n fermion pip install openfermion \ cirq \ openfermioncirq \ openfermionpsi4 \ openfermionpyscf
46+
47+
# Install PySCF
48+
WORKDIR /root
49+
RUN git clone https://github.com/sunqm/pyscf
50+
WORKDIR /root/pyscf/pyscf/lib/build
51+
RUN cmake .. && \
5452
make
5553

5654
# Activate venv (fermion)

0 commit comments

Comments
 (0)