Skip to content

Speed up Docker build#3841

Merged
GuySten merged 7 commits intoopenmc-dev:developfrom
paulromano:speedup-docker-build
Mar 1, 2026
Merged

Speed up Docker build#3841
GuySten merged 7 commits intoopenmc-dev:developfrom
paulromano:speedup-docker-build

Conversation

@paulromano
Copy link
Contributor

@paulromano paulromano commented Feb 26, 2026

Description

This PR makes a few updates to our Dockerfile to speed up build times:

  • Instead of building Embree from source it uses the apt package
  • Similarly, pugixml, libfmt, and Catch2 are installed from apt
  • Avoids building tests for MOAB and DAGMC

The Embree change alone should shave off 15-20 min of build time.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@paulromano paulromano requested a review from shimwell as a code owner February 26, 2026 22:48
@GuySten
Copy link
Contributor

GuySten commented Feb 26, 2026

If we use fmt and pugixml from apt, we should not include them as submodules.

@paulromano
Copy link
Contributor Author

We include the submodules as a backup so that people are not required to have them installed already. However, if they do have them installed and find_package finds them, the submodules don't get built.

@shimwell shimwell self-assigned this Feb 27, 2026
@shimwell
Copy link
Member

I am running this locally and getting a warning and error. I think the warning was there before the PR but is anyone else getting Unable to locate package libcatch2-dev.

The CI doesn't test this docker build till it is pushed to develop so this is why I was building locally

docker build -t openmc_dagmc --build-arg build_dagmc=on --build-arg compile_cores=4 .
[+] Building 11.6s (5/12)                                                                                                                                                docker:default
 => [internal] load build definition from Dockerfile                                                                                                                               0.1s
 => => transferring dockerfile: 8.63kB                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/ubuntu:24.04                                                                                                                    0.6s
 => [internal] load .dockerignore                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => CACHED [dependencies 1/7] FROM docker.io/library/ubuntu:24.04@sha256:d1e2e92c075e5ca139d51a140fff46f84315c0fdce203eab2807c7e495eff4f9                                          0.0s
 => ERROR [dependencies 2/7] RUN apt-get update -y &&     apt-get upgrade -y &&     apt-get install -y         python3-pip python-is-python3 wget git build-essential cmake       10.8s
------                                                                                                                                                                                  
 > [dependencies 2/7] RUN apt-get update -y &&     apt-get upgrade -y &&     apt-get install -y         python3-pip python-is-python3 wget git build-essential cmake         mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev         libpng-dev libpugixml-dev libfmt-dev libcatch2-dev python3-venv &&     apt-get autoremove:                                         
0.366 Get:1 http://archive.ubuntu.com/ubuntu noble InRelease [256 kB]                                                                                                                   
0.522 Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]                                                                                                         
0.631 Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]                                                                                                           
0.696 Get:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
0.760 Get:5 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [19.3 MB]
1.083 Get:6 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Packages [34.8 kB]
1.227 Get:7 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [1242 kB]
1.689 Get:8 http://archive.ubuntu.com/ubuntu noble/restricted amd64 Packages [117 kB]
1.690 Get:9 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages [1808 kB]
1.744 Get:10 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Packages [331 kB]
1.752 Get:11 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Packages [38.1 kB]
1.753 Get:12 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [2017 kB]
1.938 Get:13 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [2275 kB]
2.006 Get:14 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [1883 kB]
2.072 Get:15 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [3471 kB]
2.141 Get:16 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [3262 kB]
2.380 Get:17 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [34.6 kB]
2.381 Get:18 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Packages [49.5 kB]
3.500 Fetched 36.5 MB in 3s (11.3 MB/s)
3.500 Reading package lists...
4.762 Reading package lists...
5.879 Building dependency tree...
6.104 Reading state information...
6.166 Calculating upgrade...
6.477 The following packages will be upgraded:
6.478   gcc-14-base libgcc-s1 libgnutls30t64 libstdc++6
6.926 4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
6.926 Need to get 1923 kB of archives.
6.926 After this operation, 9216 B of additional disk space will be used.
6.926 Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 gcc-14-base amd64 14.2.0-4ubuntu2~24.04.1 [51.0 kB]
7.438 Get:2 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libstdc++6 amd64 14.2.0-4ubuntu2~24.04.1 [792 kB]
7.993 Get:3 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libgcc-s1 amd64 14.2.0-4ubuntu2~24.04.1 [78.4 kB]
8.009 Get:4 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libgnutls30t64 amd64 3.8.3-1.1ubuntu3.5 [1001 kB]
8.371 debconf: delaying package configuration, since apt-utils is not installed
8.436 Fetched 1923 kB in 2s (1172 kB/s)
(Reading database ... 4381 files and directories currently installed.)
8.474 Preparing to unpack .../gcc-14-base_14.2.0-4ubuntu2~24.04.1_amd64.deb ...
8.482 Unpacking gcc-14-base:amd64 (14.2.0-4ubuntu2~24.04.1) over (14.2.0-4ubuntu2~24.04) ...
8.540 Setting up gcc-14-base:amd64 (14.2.0-4ubuntu2~24.04.1) ...
(Reading database ... 4381 files and directories currently installed.)
8.593 Preparing to unpack .../libstdc++6_14.2.0-4ubuntu2~24.04.1_amd64.deb ...
8.625 Unpacking libstdc++6:amd64 (14.2.0-4ubuntu2~24.04.1) over (14.2.0-4ubuntu2~24.04) ...
8.724 Setting up libstdc++6:amd64 (14.2.0-4ubuntu2~24.04.1) ...
(Reading database ... 4381 files and directories currently installed.)
8.773 Preparing to unpack .../libgcc-s1_14.2.0-4ubuntu2~24.04.1_amd64.deb ...
8.781 Unpacking libgcc-s1:amd64 (14.2.0-4ubuntu2~24.04.1) over (14.2.0-4ubuntu2~24.04) ...
8.834 Setting up libgcc-s1:amd64 (14.2.0-4ubuntu2~24.04.1) ...
(Reading database ... 4381 files and directories currently installed.)
8.881 Preparing to unpack .../libgnutls30t64_3.8.3-1.1ubuntu3.5_amd64.deb ...
8.889 Unpacking libgnutls30t64:amd64 (3.8.3-1.1ubuntu3.5) over (3.8.3-1.1ubuntu3.4) ...
8.964 Setting up libgnutls30t64:amd64 (3.8.3-1.1ubuntu3.5) ...
8.993 Processing triggers for libc-bin (2.39-0ubuntu8.7) ...
9.053 Reading package lists...
10.42 Building dependency tree...
10.71 Reading state information...
10.74 E: Unable to locate package libcatch2-dev
------

 1 warning found (use docker --debug to expand):
 - UndefinedVar: Usage of undefined variable '$LD_LIBRARY_PATH' (line 59)
Dockerfile:64
--------------------
  63 |     # Install and update dependencies from Debian package manager
  64 | >>> RUN apt-get update -y && \
  65 | >>>     apt-get upgrade -y && \
  66 | >>>     apt-get install -y \
  67 | >>>         python3-pip python-is-python3 wget git build-essential cmake \
  68 | >>>         mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev \
  69 | >>>         libpng-dev libpugixml-dev libfmt-dev libcatch2-dev python3-venv && \
  70 | >>>     apt-get autoremove
  71 |     
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c apt-get update -y &&     apt-get upgrade -y &&     apt-get install -y         python3-pip python-is-python3 wget git build-essential cmake         mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev         libpng-dev libpugixml-dev libfmt-dev libcatch2-dev python3-venv &&     apt-get autoremove" did not complete successfully: exit code: 100

@paulromano
Copy link
Contributor Author

Thanks for testingit out @shimwell! Apparently libcatch2-dev wasn't present as an apt package until Ubuntu 25.04. The correct name for Ubuntu 24.04 is catch2. I just updated that and built locally and it seems to work now.

Copy link
Member

@shimwell shimwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the speed improvements, keen to see this as it will help keep the reduce CI usage. I committed a small change to get rid of a warning, hope this is ok.

@GuySten GuySten merged commit 83a7b36 into openmc-dev:develop Mar 1, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants