Skip to content

Commit

Permalink
docker: add option to install gcc 14
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Feb 7, 2025
1 parent 5a6d48e commit f001e8b
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions docker/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
# architectures using GCC compilers and OpenMPI.
##############################################################

ARG OMPI_BRANCH="v4.1.4"

# Base image
FROM ubuntu:22.04 as base
FROM ubuntu:22.04 AS base

ARG gcc=""

ENV DEBIAN_FRONTEND=noninteractive

ENV DEBIAN_FRONTEND noninteractive
# Add repo for other python versions
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa

# Install python
RUN apt-get update && \
Expand All @@ -20,44 +25,57 @@ RUN apt-get install -y vim wget git flex libnuma-dev tmux \
numactl hwloc curl \
autoconf libtool build-essential procps software-properties-common


# Install compilersx
RUN if [ -n "$gcc" ]; then \
apt-get install libgmp-dev libmpc-dev libmpfr-dev libisl-dev -y && \
cd /tmp && mkdir gcc && \
git clone git://gcc.gnu.org/git/gcc.git gcc && \
cd gcc && git checkout releases/gcc-${gcc} && \
mkdir build && cd build && \
../configure --prefix=/opt/gcc-${gcc} --enable-languages=c,c++,fortran --disable-multilib \
--enable-shared --enable-lto --enable-threads=posix --enable-libstdcxx-time=yes --enable-libgomp && \
make -j $(nproc) && make install && \
# Update alternatives
update-alternatives --install /usr/bin/gcc gcc /opt/gcc-${gcc}/bin/gcc 60 && \
update-alternatives --install /usr/bin/g++ g++ /opt/gcc-${gcc}/bin/g++ 60 && \
update-alternatives --install /usr/bin/gfortran gfortran /opt/gcc-${gcc}/bin/gfortran 60 && \
rm -rf /tmp/gcc; \
fi;

# Install tmpi
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi

# Install OpenGL library, necessary for the installation of GemPy
RUN apt-get install -y libgl1-mesa-glx
RUN apt-get install -y libgl1-mesa-glx | echo "Skipping libgl1-mesa-glx installation, outdated"
RUN apt-get install -y libgl1 libglx-mesa0 | echo "Skipping libgl1 libglx-mesa0 installation, not recent enough"

RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

EXPOSE 8888
CMD ["/bin/bash"]

##############################################################
# GCC standard image
##############################################################
FROM base as gcc

# Install gcc 13 for better hardware and software support
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && apt update && \
apt install gcc-13 g++-13 -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100

ARG OMPI_BRANCH="v4.1.4"
ARG OMPI_BRANCH="v5.0.x"
# Install OpenMPI
RUN mkdir -p /deps && mkdir -p /opt/openmpi && cd /deps && \
RUN cd /tmp && mkdir openmpi && \
git clone --depth 1 --recursive --branch ${OMPI_BRANCH} https://github.com/open-mpi/ompi.git openmpi && \
cd openmpi && ./autogen.pl && \
mkdir build && cd build && \
../configure --prefix=/opt/openmpi/ \
--enable-mca-no-build=btl-uct --enable-mpi1-compatibility && \
make -j ${nproc} && \
make install && \
cd /deps && rm -rf /deps/openmpi
cd /tmp && rm -rf /tmp/openmpi

# Set OpenMPI path
ENV PATH=${PATH}:/opt/openmpi/bin
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/openmpi/lib
ENV LD_LIBRARY_PATH=/opt/openmpi/lib

EXPOSE 8888
CMD ["/bin/bash"]

##############################################################
# GCC standard image
##############################################################
FROM base AS gcc

# Env vars defaults
ENV DEVITO_ARCH="gcc"
Expand Down

0 comments on commit f001e8b

Please sign in to comment.