Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkumar committed Nov 18, 2023
1 parent a2b018d commit 5b66e87
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 2 deletions.
100 changes: 100 additions & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# First stage
# ===================================
FROM --platform=linux/amd64 ubuntu:22.04 as intermediate

RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential gfortran git m4 wget cmake ninja-build \
libopenblas-dev libfftw3-dev libhdf5-dev libhdf5-serial-dev libnetcdf-dev libnetcdff-dev libgl1-mesa-dev \
python3-dev python3-pip python3-venv

# Install mpich manually
WORKDIR /src
ARG mpich=4.0.3
ARG mpich_prefix=mpich-$mpich

RUN \
wget https://www.mpich.org/static/downloads/$mpich/$mpich_prefix.tar.gz && \
tar xvzf $mpich_prefix.tar.gz && \
cd $mpich_prefix && \
FFLAGS=-fallow-argument-mismatch FCFLAGS=-fallow-argument-mismatch ./configure && \
make -j 4 && \
make install && \
make clean && \
cd .. && \
rm -rf $mpich_prefix


RUN /sbin/ldconfig

RUN \
git clone --depth 1 https://github.com/Reference-ScaLAPACK/scalapack.git scalapack && \
mkdir scalapack/build && \
cd scalapack/build && \
CC=mpicc F77=mpif77 FC=mpif90 CXX=mpicxx cmake -DBUILD_SHARED_LIBS=ON -GNinja .. && \
cmake --build . 2>&1 | tee scalapack_build.log && \
cmake --install . 2>&1 | tee scalapack_install.log

RUN /sbin/ldconfig

RUN python3 -m pip install wheel
RUN python3 -m venv /venv/

RUN /venv/bin/pip install -U pip
RUN /venv/bin/python -m pip install numpy scipy jax jaxlib f90nml mpi4py jupyter notebook jupyterlab ipython qsc sympy scikit-build ninja "pybind11[global]" cmake
RUN /venv/bin/pip install git+https://github.com/zhucaoxiang/f90wrap
ENV PATH="/venv/bin:${PATH}"

RUN git clone --depth 1 https://github.com/PrincetonUniversity/SPEC.git /src/SPEC && \
cd /src/SPEC && \
/venv/bin/pip install -v . 2>&1 | tee spec_build.log

RUN git clone --depth 1 https://github.com/hiddenSymmetries/VMEC2000.git /src/VMEC && \
cd /src/VMEC && \
cp cmake/machines/ubuntu.json cmake_config_file.json && \
/venv/bin/pip install -v . 2>&1 | tee vmec_build.log

RUN /venv/bin/pip install h5py pyoculus py_spec
RUN /venv/bin/pip install vtk==9.2.6 pyqt5 matplotlib pyevtk plotly
RUN /venv/bin/pip install mayavi
RUN /venv/bin/pip install git+https://github.com/hiddenSymmetries/booz_xform
RUN /venv/bin/pip install git+https://github.com/hiddenSymmetries/virtual-casing
RUN /venv/bin/pip install git+https://github.com/rogeriojorge/pyQIC
RUN /venv/bin/pip install git+https://github.com/landreman/pyQSC

# ENV CI=True
# RUN git clone --recurse-submodules https://github.com/hiddenSymmetries/simsopt.git /src/simsopt && \
# cd /src/simsopt && \
# git fetch --tags --all && \
# /venv/bin/pip install -v .

# Get the failure logs by uncommenting the two lines following # === and running
# DOCKER_BUILDKIT=1 docker build -t test -f Dockerfile.ubuntu . --target=fail-logs --output type=local,dest=./output/
# For Mac, don't forget sudo before docker command
# ========================================
#FROM scratch AS fail-logs
#COPY --from=intermediate /src /output

# Second stage
# ===================================
FROM --platform=linux/amd64 ubuntu:22.04

LABEL maintainer.name="Bharat Medasani" \
maintainer.email="mbkumar.at.gmail" \
developers="Hidden Symmetries Team" \
version="0.07" \
description="Docker file for simsopt container based on ubuntu image"

RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y m4 vim emacs nano git wget \
libfftw3-dev libopenblas-dev libhdf5-serial-dev libnetcdf-dev libnetcdff-dev libgl1-mesa-dev \
python3-dev python3-venv

COPY --from=intermediate /venv /venv
COPY --from=intermediate /usr/local /usr/local
RUN /sbin/ldconfig
COPY entrypoint.sh /venv/bin

#env PATH=$PATH:/venv/bin
# ENV OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
ENTRYPOINT ["bash", "/venv/bin/entrypoint.sh"]
CMD ["bash"]
54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# dev_container
Builds development container with all the dependencies built
# Simsopt and Docker Containers


This document explains how to build docker container for simsopt. It also provides
instructions on how to run simsopt docker container


## Build the container

0. Install docker
1. Build the docker image by running the `docker build` command:

```bash
docker build -t <[user_name/]image_name:[tag]> -f Dockerfile.ubuntu .
# In the above command, user_name is typically used for uploading the image to docker hub
# For local builds, you can omit the user_name/ and just use your choice of image_name
# Tag is optional. If not given, default is latest
```
2. Upload the image to docker hub if you want to distribute it
```bash
docker push <image_name:tag>
```


## Run the container
There are two cases here: 1) docker image is built locally and 2) docker image downloaded from a repo

### For local builds:
0. Identify the local image using the command
```bash
docker image ls
```
After identifying the image built locally, you can use either <image_name:tag> or the image id, which
is an hexadecimal number, to run the docker image in the next command

### Remote repo
0. Assuming image is uploaded to docker hub, use the <user_name/image_name:tag> to automatically download
the image in the next command

1. For interactive runs, run the docker container with the command:
```bash
docker run -it --rm <image>
```

2. To execute a python script
```bash
docker run -v$PWD:$PWD <image> python3 $PWD/<python_script>
```
**This command works only if no additional files are needed to run the script**



5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# Read in the file of environment settings
source /venv/bin/activate
# Then run the CMD
exec "$@"

0 comments on commit 5b66e87

Please sign in to comment.