Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 48c8b36

Browse files
authored
PR #1828: reduce build-and-install example to one image
1 parent 40c4422 commit 48c8b36

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

doc/best_practices.rst

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -182,46 +182,41 @@ Third-party software compiled from source
182182
-----------------------------------------
183183

184184
Under this method, one uses :code:`RUN` commands to fetch the desired software
185-
using :code:`curl` or :code:`wget`, compile it, and install. Our example does
186-
this with two chained Dockerfiles. First, we build a basic AlmaLinux image
187-
(:code:`examples/Dockerfile.almalinux_8ch`):
185+
using :code:`curl` or :code:`wget`, compile it, and install. Our example
186+
(:code:`examples/Dockerfile.almalinux_8ch`) does this with ImageMagick:
188187

189-
.. literalinclude:: ../examples/Dockerfile.almalinux_8ch
190-
:language: docker
191-
:lines: 2-
192-
193-
Then, in a second image (:code:`examples/Dockerfile.openmpi`), we add OpenMPI.
194-
This is a complex Dockerfile that compiles several dependencies in addition to
195-
OpenMPI. For the purposes of this documentation, you can skip most of it, but
196-
we felt it would be useful to show a real example.
197-
198-
.. literalinclude:: ../examples/Dockerfile.openmpi
188+
.. literalinclude:: ../examples/Dockerfile.almalinux_8ch
199189
:language: docker
200190
:lines: 2-
201191

202192
So what is going on here?
203193

204-
1. Use the latest AlmaLinux 8 as the base image.
194+
#. Use the latest AlmaLinux 8 as the base image.
195+
196+
#. Install some packages using :code:`dnf`, the OS package manager, including
197+
a basic development environment.
205198

206-
2. Install a basic build system using the OS package manager.
199+
#. Install :code:`wheel` using :code:`pip` and adjust the shared library
200+
configuration. (These are not needed for ImageMagick but rather support
201+
derived images.)
207202

208-
3. For a few dependencies and then OpenMPI itself:
203+
#. For ImageMagick itself:
209204

210-
1. Download and untar. Note the use of variables to make adjusting the URL
211-
and versions easier, as well as the explanation of why we’re not using
212-
:code:`dnf`, given that several of these packages are included in
213-
CentOS.
205+
#. Download and untar. Note the use of the variable :code:`MAGICK_VERSION`
206+
and versions easier.
214207

215-
2. Build and install OpenMPI. Note the :code:`getconf` trick to guess at an
208+
#. Build and install. Note the :code:`getconf` trick to guess at an
216209
appropriate parallel build.
217210

218-
4. Clean up, in order to reduce the size of the build cache as well as the
219-
resulting Charliecloud image (:code:`rm -Rf`).
211+
#. Clean up, in order to reduce the size of the build cache as well as the
212+
resulting Charliecloud image (:code:`rm -Rf`).
213+
214+
.. note::
220215

221-
.. Finally, because it’s a container image, you can be less tidy than you
222-
might be on a normal system. For example, the above downloads and builds in
223-
:code:`/` rather than :code:`/usr/local/src`, and it installs MPI into
224-
:code:`/usr` rather than :code:`/usr/local`.
216+
Because it’s a container image, you can be less tidy than you might
217+
normally be. For example, we install ImageMagick directly into
218+
:code:`/usr/local` rather than using something like `GNU Stow
219+
<https://www.gnu.org/software/stow/>`_ to organize this directory tree.
225220

226221
Your software stored in the image
227222
---------------------------------
@@ -309,4 +304,4 @@ terminal.
309304

310305

311306
.. LocalWords: userguide Gruening Souppaya Morello Scarfone openmpi nist
312-
.. LocalWords: ident OCFS
307+
.. LocalWords: ident OCFS MAGICK

0 commit comments

Comments
 (0)