@@ -16,7 +16,6 @@ ARG TARGETARCH
1616# Install RPM build tools and dependencies
1717RUN set -ex \
1818 && dnf makecache \
19- && dnf -y update \
2019 && dnf -y install dnf-plugins-core epel-release \
2120 && dnf config-manager --set-enabled crb \
2221 && dnf makecache \
@@ -92,17 +91,14 @@ LABEL org.opencontainers.image.source="https://github.com/giovtorres/slurm-docke
9291ARG SLURM_VERSION
9392ARG TARGETARCH
9493
95- # Enable CRB and EPEL repositories for runtime dependencies
94+ # Enable CRB and EPEL repositories, then install runtime dependencies
9695RUN set -ex \
97- && dnf makecache \
9896 && dnf -y update \
9997 && dnf -y install dnf-plugins-core epel-release \
10098 && dnf config-manager --set-enabled crb \
101- && dnf makecache
102-
103- # Install runtime dependencies only
104- RUN set -ex \
99+ && dnf makecache \
105100 && dnf -y install \
101+ apptainer \
106102 bash-completion \
107103 bzip2 \
108104 gettext \
@@ -132,16 +128,21 @@ RUN set -ex \
132128
133129# Install gosu for privilege dropping
134130ARG GOSU_VERSION=1.19
131+ # Official SHA256 checksums from https://github.com/tianon/gosu/releases/download/1.19/SHA256SUMS
132+ ARG GOSU_SHA256_AMD64=52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0
133+ ARG GOSU_SHA256_ARM64=3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44
135134
136135RUN set -ex \
137- && echo "Installing gosu for architecture: ${TARGETARCH}" \
138- && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-${TARGETARCH}" \
139- && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-${TARGETARCH}.asc" \
140- && export GNUPGHOME="$(mktemp -d)" \
141- && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
142- && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
143- && rm -rf "${GNUPGHOME}" /usr/local/bin/gosu.asc \
136+ && echo "Installing gosu ${GOSU_VERSION} for architecture: ${TARGETARCH}" \
137+ && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${TARGETARCH}" \
138+ && EXPECTED_SHA256=$(case "${TARGETARCH}" in \
139+ amd64) echo "${GOSU_SHA256_AMD64}" ;; \
140+ arm64) echo "${GOSU_SHA256_ARM64}" ;; \
141+ *) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
142+ esac) \
143+ && echo "${EXPECTED_SHA256} /usr/local/bin/gosu" | sha256sum -c - \
144144 && chmod +x /usr/local/bin/gosu \
145+ && gosu --version \
145146 && gosu nobody true
146147
147148COPY --from=builder /root/rpmbuild/RPMS/*/*.rpm /tmp/rpms/
@@ -158,27 +159,14 @@ RUN set -ex \
158159 && rm -rf /tmp/rpms \
159160 && dnf clean all
160161
161- # Install Singularity
162- RUN set -ex \
163- && dnf -y install \
164- apptainer \
165- && dnf clean all \
166- && rm -rf /var/cache/dnf
167-
168- # Create slurm user and group
162+ # Create users, generate munge key, and set up directories
169163RUN set -x \
170164 && groupadd -r --gid=990 slurm \
171165 && useradd -r -g slurm --uid=990 slurm \
172166 && groupadd -r --gid=991 slurmrest \
173- && useradd -r -g slurmrest --uid=991 slurmrest
174-
175- # Fix /etc permissions and create munge key
176- RUN set -x \
167+ && useradd -r -g slurmrest --uid=991 slurmrest \
177168 && chmod 0755 /etc \
178- && /sbin/create-munge-key
179-
180- # Create slurm dirs with correct ownership
181- RUN set -x \
169+ && /sbin/create-munge-key \
182170 && mkdir -m 0755 -p \
183171 /var/run/slurm \
184172 /var/spool/slurm \
0 commit comments