Skip to content

Commit

Permalink
Merge pull request #117 from dynamicslab/lp/patch-1
Browse files Browse the repository at this point in the history
Improvement of Developer's Experience
  • Loading branch information
ludgerpaehler authored Jan 31, 2024
2 parents be19901 + 35ec4a9 commit fa2d530
Show file tree
Hide file tree
Showing 13 changed files with 301 additions and 87 deletions.
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "HydroGym Devpod",

// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// pulling from Dockerhub
"image": "lpaehler/hydrogym-devpod:stable",
"features": {
"ghcr.io/devcontainers-contrib/features/black:2": {},
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
"ghcr.io/devcontainers-contrib/features/ruff:1": {}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// Setting up an editable version of HydroGym
"postCreateCommand": "pip install -e ."

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .packaging/Dockerfile.devpod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Full Firedrake pre-installed with all of it enabled
FROM lpaehler/hydrogym-env:stable

# Activation of the virtual environment
RUN bash -c "source firedrake/bin/activate"

# Clone HydroGym
RUN bash -c "git clone https://github.com/dynamicslab/hydrogym.git"

# Installation of HydroGym's dependencies, and only the
# the dependencies
RUN bash -c "cd hydrogym && pip install -r requirements.txt"
167 changes: 167 additions & 0 deletions .packaging/Dockerfile.firedrake_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# DockerFile for an environment into which firedrake can be installed.
# entirely based on:
# https://github.com/firedrakeproject/firedrake/blob/master/docker/Dockerfile.env
FROM ubuntu:22.04

# Update and install required packages for Firedrake
USER root
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get -y dist-upgrade \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata \
&& apt-get -y install curl vim docker.io \
openssh-client build-essential autoconf automake \
cmake gfortran git libopenblas-serial-dev \
libtool python3-dev python3-pip python3-tk python3-venv \
python3-requests zlib1g-dev libboost-dev sudo gmsh \
bison flex \
liboce-ocaf-dev \
swig graphviz \
libcurl4-openssl-dev libxml2-dev \
&& rm -rf /var/lib/apt/lists/*

# Use a more sane locale
ENV LC_ALL C.UTF-8

# Set up user so that we do not run as root
RUN useradd -m -s /bin/bash -G sudo firedrake && \
echo "firedrake:docker" | chpasswd && \
echo "firedrake ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
ldconfig

USER firedrake
WORKDIR /home/firedrake

# Fetch PETSc, SLEPc and eigen
RUN git clone https://github.com/firedrakeproject/petsc.git
RUN git clone https://github.com/firedrakeproject/slepc.git

# Build MPICH manually because we don't want PETSc to build it twice
RUN bash -c 'cd petsc; \
./configure \
--COPTFLAGS=-O3 -march=native -mtune=native \
--CXXOPTFLAGS=-O3 -march=native -mtune=native \
--FOPTFLAGS=-O3 -march=native -mtune=native \
--with-c2html=0 \
--with-debugging=0 \
--with-fortran-bindings=0 \
--with-make-np=12 \
--with-shared-libraries=1 \
--with-zlib \
--download-chaco \
--download-fftw \
--download-hdf5 \
--download-hwloc \
--download-hypre \
--download-metis \
--download-ml \
--download-mumps \
--download-mpich \
--download-mpich-device=ch3:sock \
--download-netcdf \
--download-pastix \
--download-pnetcdf \
--download-ptscotch \
--download-scalapack \
--download-suitesparse \
--download-superlu_dist \
PETSC_ARCH=packages; \
mv packages/include/petscconf.h packages/include/old_petscconf.nope;'
# Don't run make here, we only want MPICH and HWLOC
# It is also necessary to move `petscconf.h` so packages isn't treated like a working PETSc

# Build default Firedrake PETSc
RUN bash -c 'export PACKAGES=/home/firedrake/petsc/packages; \
cd petsc; \
./configure \
--COPTFLAGS=-O3 -march=native -mtune=native \
--CXXOPTFLAGS=-O3 -march=native -mtune=native \
--FOPTFLAGS=-O3 -march=native -mtune=native \
--with-c2html=0 \
--with-debugging=0 \
--with-fortran-bindings=0 \
--with-make-np=12 \
--with-shared-libraries=1 \
--with-bison \
--with-flex \
--with-zlib \
--with-chaco-dir=$PACKAGES \
--with-fftw-dir=$PACKAGES \
--with-hdf5-dir=$PACKAGES \
--with-hwloc-dir=$PACKAGES \
--with-hypre-dir=$PACKAGES \
--with-metis-dir=$PACKAGES \
--with-ml-dir=$PACKAGES \
--with-mpi-dir=$PACKAGES \
--with-mumps-dir=$PACKAGES \
--with-netcdf-dir=$PACKAGES \
--with-pastix-dir=$PACKAGES \
--with-pnetcdf-dir=$PACKAGES \
--with-ptscotch-dir=$PACKAGES \
--with-scalapack-dir=$PACKAGES \
--with-suitesparse-dir=$PACKAGES \
--with-superlu_dist-dir=$PACKAGES \
PETSC_ARCH=default; \
make PETSC_DIR=/home/firedrake/petsc PETSC_ARCH=default all;'

# Build default Firedrake SLEPc
RUN bash -c 'export PETSC_DIR=/home/firedrake/petsc; \
export PETSC_ARCH=default; \
cd slepc; \
./configure; \
make SLEPC_DIR=/home/firedrake/slepc PETSC_DIR=/home/firedrake/petsc PETSC_ARCH=default;'

# Additionally build complex PETSc for Firedrake
RUN bash -c 'export PACKAGES=/home/firedrake/petsc/packages; \
cd petsc; \
./configure \
--COPTFLAGS=-O3 -march=native -mtune=native \
--CXXOPTFLAGS=-O3 -march=native -mtune=native \
--FOPTFLAGS=-O3 -march=native -mtune=native \
--with-c2html=0 \
--with-debugging=0 \
--with-fortran-bindings=0 \
--with-make-np=12 \
--with-scalar-type=complex \
--with-shared-libraries=1 \
--with-bison \
--with-flex \
--with-zlib \
--with-chaco-dir=$PACKAGES \
--with-fftw-dir=$PACKAGES \
--with-hdf5-dir=$PACKAGES \
--with-hwloc-dir=$PACKAGES \
--with-metis-dir=$PACKAGES \
--with-mpi-dir=$PACKAGES \
--with-mumps-dir=$PACKAGES \
--with-netcdf-dir=$PACKAGES \
--with-pastix-dir=$PACKAGES \
--with-pnetcdf-dir=$PACKAGES \
--with-ptscotch-dir=$PACKAGES \
--with-scalapack-dir=$PACKAGES \
--with-suitesparse-dir=$PACKAGES \
--with-superlu_dist-dir=$PACKAGES \
PETSC_ARCH=complex; \
make PETSC_DIR=/home/firedrake/petsc PETSC_ARCH=complex all;'

# Build complex Firedrake SLEPc
RUN bash -c 'export PETSC_DIR=/home/firedrake/petsc; \
export PETSC_ARCH=complex; \
cd slepc; \
./configure; \
make SLEPC_DIR=/home/firedrake/slepc PETSC_DIR=/home/firedrake/petsc PETSC_ARCH=complex;'

# Clean up unnecessary files
RUN rm -rf /home/firedrake/petsc/**/externalpackages \
&& rm -rf /home/firedrake/petsc/src/docs \
&& rm -f /home/firedrake/petsc/src/**/tutorials/output/* \
&& rm -f /home/firedrake/petsc/src/**/tests/output/*

# Set some useful environment variables
ENV PETSC_DIR /home/firedrake/petsc
ENV SLEPC_DIR /home/firedrake/slepc
ENV MPICH_DIR /home/firedrake/petsc/packages/bin
ENV HDF5_DIR /home/firedrake/petsc/packages
ENV HDF5_MPI ON
ENV OMP_NUM_THREADS 1
ENV OPENBLAS_NUM_THREADS 1
19 changes: 19 additions & 0 deletions .packaging/Dockerfile.hydrogym
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dockerfile with HydroGym included
# --> highly unstable for now.

FROM lpaehler/hydrogym-env:stable

USER firedrake
WORKDIR /home/firedrake

# Activation of the virtual environment
RUN bash -c "source firedrake/bin/activate"

# Clone HydroGym
RUN bash -c "git clone https://github.com/dynamicslab/hydrogym.git"

# Installation of HydroGym
RUN bash -c "cd hydrogym && pip install ."

#RUN bash -c ". $VENV/bin/activate && pip install -e /home/hydrogym"
#RUN bash -c ". $VENV_COMPLEX/bin/activate && pip install -e /home/hydrogym"
37 changes: 37 additions & 0 deletions .packaging/Dockerfile.hydrogym_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dockerfile for a fully enabled Firedrake as base environment for HydroGym
# Based on:
# https://github.com/firedrakeproject/firedrake/blob/master/docker/Dockerfile.vanilla
# https://github.com/firedrakeproject/firedrake/blob/master/docker/Dockerfile.firedrake

FROM lpaehler/hydrogym-firedrake-env:stable

USER firedrake
WORKDIR /home/firedrake

ENV PETSC_ARCH default

# Installation of basic Firedrake.
RUN curl -O https://raw.githubusercontent.com/firedrakeproject/firedrake/master/scripts/firedrake-install
RUN bash -c "python3 firedrake-install \
--no-package-manager \
--disable-ssh \
--torch \
--honour-petsc-dir \
--mpicc=$MPICH_DIR/mpicc \
--mpicxx=$MPICH_DIR/mpicxx \
--mpif90=$MPICH_DIR/mpif90 \
--mpiexec=$MPICH_DIR/mpiexec"

# Installation of extra Firedrake components.
RUN bash -c "source firedrake/bin/activate; \
firedrake-update \
--documentation-dependencies \
--netgen \
--slepc \
--tinyasm \
--install femlium \
--install fascd \
--install gusto \
--install icepack \
--install irksome \
--install thetis"
3 changes: 0 additions & 3 deletions .packaging/build.sh

This file was deleted.

41 changes: 0 additions & 41 deletions .packaging/docker/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions .packaging/docker/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions .packaging/launch.sh

This file was deleted.

19 changes: 0 additions & 19 deletions .packaging/petsc_config.sh

This file was deleted.

Loading

0 comments on commit fa2d530

Please sign in to comment.