Skip to content

Commit

Permalink
deps: add install-deps.sh script, use in docker
Browse files Browse the repository at this point in the history
problem: it's easy to accidentally miss adding or removing a dependency
in the various dockerfiles and the readme

solution: much like core, encode them as a script, then use it
  • Loading branch information
trws committed Aug 27, 2024
1 parent 4606f7c commit 564d1f5
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 119 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Fluxion requires an installed flux-core package. Instructions
for installing flux-core can be found in [the flux-core
README](https://github.com/flux-framework/flux-core/blob/master/README.md).

To install our other dependencies on a dnf, apk or apt-using distro you should
be able to use ./scripts/install-deps.sh to install all necessary dependencies.

<!-- A collapsible section with markdown -->
<details>
<summary>Click to expand and see our full dependency table</summary>
Expand All @@ -60,15 +63,6 @@ libedit-devel | libedit-dev | >= 3.0 |
python3-pyyaml | python3-yaml | >= 3.10 |
yaml-cpp-devel | libyaml-cpp-dev | >= 0.5.1 |

*Note 1 - Boost package versions 1.54-1.58 contain a bug that
leads to compilation error.*

The following optional dependencies enable additional testing:

**redhat** | **ubuntu** | **version**
---------- | ---------- | -----------
valgrind-devel | valgrind |
jq | jq |
</details>

##### Installing RedHat/CentOS Packages
Expand Down Expand Up @@ -156,7 +150,7 @@ from the source directory or use the usual ctest options to filter by regex:

```bash
$ cd build/t
$ ../../t/t9001-golang-basic.t
$ ../../t/t9001-golang-basic.t
ok 1 - match allocate 1 slot: 1 socket: 1 core (pol=default)
ok 2 - match allocate 2 slots: 2 sockets: 5 cores 1 gpu 6 memory
# passed all 2 test(s)
Expand Down
14 changes: 14 additions & 0 deletions scripts/add_docker_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
if test "$USER" != "flux"; then
sudo groupadd -g $UID $USER
sudo useradd -g $USER -u $UID -d /home/$USER -m $USER
sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers"
case "$ID" in
ubuntu|debian)
sudo adduser $USER sudo
;;
fedora|rocky|alma|rhel|centos|alpine)
sudo usermod -G wheel $USER
;;
esac
fi
67 changes: 67 additions & 0 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

if [ -z "$ID" ] ; then
while IFS== read -r key value; do
value="${value%\"}"
value="${value#\"}"
export "$key"="$value"
done </etc/os-release
fi

PM=""
case "$ID" in
ubuntu|debian)
PM=apt
DEV_SUFFIX="-dev"
DEV_SUFFIX_APT="-dev"
PY3_PREFIX="python3-"
LIB_PREFIX="lib"
;;
fedora|rocky|alma|rhel|centos)
PM=dnf
DEV_SUFFIX="-devel"
PY3_PREFIX="python3-"
LIB_PREFIX=""
;;
alpine)
PM=apk
DEV_SUFFIX="-dev"
PY3_PREFIX="py3-"
LIB_PREFIX=""
;;
esac

[ -z "$PM" ] && echo Package manager for $ID is unknown && exit 1

pkglist="
${LIB_PREFIX}boost${DEV_SUFFIX}
${LIB_PREFIX}boost-graph${DEV_SUFFIX_APT}
libedit${DEV_SUFFIX}
${LIB_PREFIX}hwloc${DEV_SUFFIX}
${PY3_PREFIX}yaml
${LIB_PREFIX}yaml-cpp${DEV_SUFFIX}
ninja-build
cmake
curl
bash
jq
valgrind
"

case $PM in
apt)
CMD="apt install ${@} ${pkglist}"
;;
apk)
CMD="apk add ${@} ${pkglist}"
;;
dnf)
CMD="dnf install ${@} ${pkglist}"
;;
esac
echo will run "'$CMD'"
if [ $(id -u) -ne 0 ]
then echo command will not work without root, re-run as root
exit 1
fi
$CMD
19 changes: 3 additions & 16 deletions src/test/docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@ ARG UID=1000
USER root

# Install extra buildrequires for flux-sched:
RUN sudo apk add \
boost-dev \
py3-yaml \
yaml-cpp-dev \
libedit-dev \
ninja-build \
cmake \
bash \
curl
COPY scripts/ /scripts
RUN sudo /scripts/install-deps.sh

# Add configured user to image with sudo access:
#
RUN \
if test "$USER" != "flux"; then \
sudo groupadd -g $UID $USER \
&& sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \
&& sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \
&& sudo usermod -G wheel $USER; \
fi
RUN /scripts/add_docker_user.sh

USER $USER
WORKDIR /home/$USER
Expand Down
23 changes: 6 additions & 17 deletions src/test/docker/bookworm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,16 @@ ARG USER=flux
ARG UID=1000
USER root

# copy scripts into image
COPY scripts/ /scripts
# Install extra buildrequires for flux-sched:
RUN apt-get update
RUN apt-get -qq install -y --no-install-recommends \
libboost-graph-dev \
libboost-system-dev \
libboost-filesystem-dev \
libboost-regex-dev \
libyaml-cpp-dev \
libedit-dev \
ninja-build \
python3-yaml
RUN sudo apt update \
&& sudo /scripts/install-deps.sh -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Add configured user to image with sudo access:
#
RUN \
if test "$USER" != "flux"; then \
groupadd -g $UID $USER \
&& useradd -g $USER -u $UID -d /home/$USER -m $USER \
&& sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \
&& adduser $USER sudo ; \
fi
RUN /scripts/add_docker_user.sh

USER $USER
WORKDIR /home/$USER
27 changes: 5 additions & 22 deletions src/test/docker/el9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,15 @@ ARG USER=flux
ARG UID=1000
USER root

# copy scripts into image
COPY scripts/ /scripts
# Install extra buildrequires for flux-sched:
RUN sudo dnf -y install \
# We need this to allow curl or others to upgrade base packages
--allowerasing \
boost-devel \
boost-graph \
boost-system \
boost-filesystem \
boost-regex \
python3-pyyaml \
yaml-cpp-devel \
libedit-devel \
ninja-build \
gcc-toolset-13-{gcc,gcc-c++,gdb} \
cmake \
curl
RUN sudo /scripts/install-deps.sh -y --allowerasing gcc-toolset-13-{gcc,gcc-c++,gdb} \
&& sudo dnf clean all

# Add configured user to image with sudo access:
#
RUN \
if test "$USER" != "flux"; then \
sudo groupadd -g $UID $USER \
&& sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \
&& sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \
&& sudo usermod -G wheel $USER; \
fi
RUN /scripts/add_docker_user.sh

USER $USER
WORKDIR /home/$USER
Expand Down
24 changes: 4 additions & 20 deletions src/test/docker/fedora40/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,15 @@ LABEL maintainer="Tom Scogland <[email protected]>"
ARG USER=flux
ARG UID=1000

# copy scripts into image
COPY scripts/ /scripts
# Install flux-sched dependencies
RUN sudo dnf -y install \
boost-devel \
boost-graph \
boost-system \
boost-filesystem \
boost-regex \
python3-pyyaml \
yaml-cpp-devel \
libedit-devel \
ninja-build \
cmake \
clang \
lcov \
RUN sudo /scripts/install-deps.sh -y \
&& sudo dnf clean all

# Add configured user to image with sudo access:
#
RUN \
if test "$USER" != "flux"; then \
sudo groupadd -g $UID $USER \
&& sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \
&& sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \
&& sudo usermod -G wheel $USER; \
fi
RUN /scripts/add_docker_user.sh

USER $USER
WORKDIR /home/$USER
23 changes: 6 additions & 17 deletions src/test/docker/jammy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,16 @@ FROM fluxrm/flux-core:jammy
ARG USER=flux
ARG UID=1000

# copy scripts into image
COPY scripts/ /scripts
# Install extra buildrequires for flux-sched:
RUN sudo apt-get update
RUN sudo apt-get -qq install -y --no-install-recommends \
libboost-graph-dev \
libboost-system-dev \
libboost-filesystem-dev \
libboost-regex-dev \
python3-yaml \
libyaml-cpp-dev \
libedit-dev \
ninja-build
RUN sudo apt update \
&& sudo /scripts/install-deps.sh -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Add configured user to image with sudo access:
#
RUN \
if test "$USER" != "flux"; then \
sudo groupadd -g $UID $USER \
&& sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \
&& sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \
&& sudo adduser $USER sudo ; \
fi
RUN /scripts/add_docker_user.sh

USER $USER
WORKDIR /home/$USER
22 changes: 5 additions & 17 deletions src/test/docker/noble/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,16 @@ ARG USER=flux
ARG UID=1000
USER root

# copy scripts into image
COPY scripts/ /scripts
# Install extra buildrequires for flux-sched:
RUN sudo apt-get update
RUN sudo apt-get -qq install -y --no-install-recommends \
libboost-graph-dev \
libboost-system-dev \
libboost-filesystem-dev \
libboost-regex-dev \
python3-yaml \
libyaml-cpp-dev \
libedit-dev \
ninja-build \
RUN sudo apt update \
&& sudo /scripts/install-deps.sh -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Add configured user to image with sudo access:
#
RUN \
if test "$USER" != "flux"; then \
sudo groupadd -g $UID $USER \
&& sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \
&& sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \
&& sudo adduser $USER sudo ; \
fi
RUN /scripts/add_docker_user.sh

USER $USER
WORKDIR /home/$USER

0 comments on commit 564d1f5

Please sign in to comment.