Skip to content

Commit 41c79f0

Browse files
committed
docker: add option to install gcc 14
1 parent 5a6d48e commit 41c79f0

2 files changed

Lines changed: 45 additions & 26 deletions

File tree

.github/workflows/docker-bases.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
runs-on: ubuntu-latest
2929
env:
3030
DOCKER_BUILDKIT: "1"
31+
strategy:
32+
matrix:
33+
version: ['', '14']
3134

3235
steps:
3336
- name: Checkout devito
@@ -57,9 +60,8 @@ jobs:
5760
context: .
5861
file: './docker/Dockerfile.cpu'
5962
push: true
60-
target: 'gcc'
61-
build-args: 'arch=gcc'
62-
tags: 'devitocodes/bases:cpu-gcc'
63+
build-args: 'gcc=${{ matrix.version }}'
64+
tags: 'devitocodes/bases:cpu-gcc${{ matrix.version }}'
6365

6466

6567
#######################################################

docker/Dockerfile.cpu

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
# architectures using GCC compilers and OpenMPI.
55
##############################################################
66

7-
ARG OMPI_BRANCH="v4.1.4"
8-
97
# Base image
10-
FROM ubuntu:22.04 as base
8+
FROM ubuntu:22.04 AS base
9+
10+
ARG gcc=""
11+
12+
ENV DEBIAN_FRONTEND=noninteractive
1113

12-
ENV DEBIAN_FRONTEND noninteractive
14+
# Add repo for other python versions
15+
RUN apt-get update && \
16+
apt-get install -y software-properties-common
1317

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

27+
28+
# Install compilersx
29+
RUN if [ -n "$gcc" ]; then \
30+
apt-get install libgmp-dev libmpc-dev libmpfr-dev libisl-dev -y && \
31+
cd /tmp && mkdir gcc && \
32+
git clone git://gcc.gnu.org/git/gcc.git gcc && \
33+
cd gcc && git checkout releases/gcc-${gcc} && \
34+
mkdir build && cd build && \
35+
../configure --prefix=/opt/gcc-${gcc} --enable-languages=c,c++,fortran --disable-multilib \
36+
--enable-shared --enable-lto --enable-threads=posix --enable-libstdcxx-time=yes --enable-libgomp && \
37+
make -j $(nproc) && make install && \
38+
# Update alternatives
39+
update-alternatives --install /usr/bin/gcc gcc /opt/gcc-${gcc}/bin/gcc 60 && \
40+
update-alternatives --install /usr/bin/g++ g++ /opt/gcc-${gcc}/bin/g++ 60 && \
41+
update-alternatives --install /usr/bin/gfortran gfortran /opt/gcc-${gcc}/bin/gfortran 60 && \
42+
rm -rf /tmp/gcc; \
43+
fi;
44+
2345
# Install tmpi
2446
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi
2547

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

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

32-
EXPOSE 8888
33-
CMD ["/bin/bash"]
34-
35-
##############################################################
36-
# GCC standard image
37-
##############################################################
38-
FROM base as gcc
39-
40-
# Install gcc 13 for better hardware and software support
41-
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && apt update && \
42-
apt install gcc-13 g++-13 -y && \
43-
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
44-
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100
45-
46-
ARG OMPI_BRANCH="v4.1.4"
55+
ARG OMPI_BRANCH="v5.0.x"
4756
# Install OpenMPI
48-
RUN mkdir -p /deps && mkdir -p /opt/openmpi && cd /deps && \
57+
RUN cd /tmp && mkdir openmpi && \
4958
git clone --depth 1 --recursive --branch ${OMPI_BRANCH} https://github.com/open-mpi/ompi.git openmpi && \
5059
cd openmpi && ./autogen.pl && \
5160
mkdir build && cd build && \
5261
../configure --prefix=/opt/openmpi/ \
5362
--enable-mca-no-build=btl-uct --enable-mpi1-compatibility && \
5463
make -j ${nproc} && \
5564
make install && \
56-
cd /deps && rm -rf /deps/openmpi
65+
cd /tmp && rm -rf /tmp/openmpi
5766

5867
# Set OpenMPI path
5968
ENV PATH=${PATH}:/opt/openmpi/bin
60-
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/openmpi/lib
69+
ENV LD_LIBRARY_PATH=/opt/openmpi/lib
70+
71+
EXPOSE 8888
72+
CMD ["/bin/bash"]
73+
74+
##############################################################
75+
# GCC standard image
76+
##############################################################
77+
FROM base AS gcc
6178

6279
# Env vars defaults
6380
ENV DEVITO_ARCH="gcc"

0 commit comments

Comments
 (0)