Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docker/cmsweb-alma9-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM cern/alma9-base:latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks a clean base image. I would suggest discussing this with Aroosha to see if there is anything that we can reuse from different images, or if CMSWEB could actually adopt this image as base for other services.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Alan,

I would recommend against adopting pypi/alma-base as the base image for other services for several reasons:

  • Lack of Generality: A base image should be minimal and serve as a common foundation for all services, regardless of the programming language or specific team requirements. alma-base is tailored to the needs of the WM group and includes packages such as curl-minimal, libcurl-minimal, vim, python3-pycurl, pip, sudo, and less. These are not broadly applicable—for example, Python is irrelevant for Go-based applications, and tools like vim are unnecessary unless one intends to log into containers for interactive editing, which we generally discourage.

  • On-Demand Tooling: Tools like vim or curl should be installed on demand within a pod when needed for debugging or maintenance. This can be done easily using standard package managers (yum, dnf, apt-get, etc.). This approach keeps the base image lean and reduces the surface area for potential vulnerabilities, while still allowing flexibility for developers. Once debugging or inspection is complete, the pod should be terminated and allowed to restart in a clean state, in line with the stateless nature of Kubernetes workloads.

  • Security implications: Each package added to a base image introduces additional dependencies and potential vulnerabilities. If a service does not require these tools, including them unnecessarily increases risk and image size without clear benefit.

While the alma-base image may be appropriate for the WM group's specific needs, I would suggest that we not promote it as the standard base for all services.

As a side note, the only consistently shared requirement across our services appears to be access to CA certificates. However, the CMSWEB team has recently transitioned to retrieving these from Kubernetes nodes, now that CERN IT provides them via cluster configuration. This might even allow us to remove them from the CMSWEB base image in the future, though that's a separate discussion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I agree with basically everything that you said.
I think the base image needs to provide requirements that we have for CERN-related systems only (mostly CAs as you pointed out). Nonetheless, if this one is still more inflated than it needs, it is already progress compared to the CC7 base image that many of the services still rely on.

LABEL author="Dennis Lee dylee@fnal.gov"

# Install EPEL repository (required for voms, fetch-crl and CA-related packages)
RUN dnf -y install epel-release && dnf -y upgrade && \
dnf install -y http://linuxsoft.cern.ch/wlcg/el9/x86_64/wlcg-repo-1.0.0-1.el9.noarch.rpm && \
dnf clean all

# Upgrade packages from the base image and install CMSWEB required packages
RUN dnf -y install fetch-crl cern-get-certificate CERN-CA-certs ca-certificates \
wlcg-voms-cms && \
dnf clean all

# Required OS packages
RUN dnf -y install vim less procps python3-pycurl pip && dnf clean all
RUN ln -s /usr/bin/python3 /usr/bin/python

RUN update-ca-trust
26 changes: 26 additions & 0 deletions docker/pypi/dmwm-base/Dockerfile.alma9
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM registry.cern.ch/cmsweb/cmsweb-alma9-base:20250506 AS cmsweb-base
FROM registry.cern.ch/cmsweb/exporters AS exporters
FROM almalinux:latest
LABEL org.opencontainers.image.authors="Alan Malta alan.malta@cern.ch"

# base image stuff: certificates, monitoring, exporters, etc
RUN mkdir /etc/grid-security
COPY --from=cmsweb-base /etc/grid-security/certificates /etc/grid-security/certificates
COPY --from=cmsweb-base /etc/grid-security/vomsdir /etc/grid-security/vomsdir
COPY --from=exporters /data/cmsweb-ping /usr/bin/cmsweb-ping
COPY --from=exporters /data/process_exporter /usr/bin/process_exporter
COPY --from=exporters /data/cpy_exporter /usr/bin/cpy_exporter

# Required OS packages
RUN dnf -y upgrade && \
dnf -y install --skip-broken curl libcurl && \
dnf -y install sudo vim less procps && \
dnf -y install python3.12 python3.12-pip python3-pycurl pip && \
dnf clean all
RUN ln -s /usr/bin/python3.12 /usr/bin/python

ENV WDIR=/data
ADD run.sh $WDIR/run.sh
ADD monitor.sh $WDIR/monitor.sh
ADD manage $WDIR/manage
WORKDIR /data
40 changes: 40 additions & 0 deletions docker/pypi/msunmerged/Dockerfile.alma9
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM registry.cern.ch/cmsweb/dmwm-base:alma9-py3.12-20250506
LABEL org.opencontainers.image.authors="Alan Malta alan.malta@cern.ch"

# Specific MSUnmerged requirements from epel repository
RUN dnf install epel-release -y && dnf clean all && \
dnf -y install python3-gfal2-util gfal2-plugin-http gfal2-plugin-dcap gfal2-plugin-file \
gfal2-plugin-srm gfal2-plugin-xrootd gfal2-plugin-gridftp gfal2-plugin-sftp && \
dnf clean all

# Specific run.sh for MSUnmerged
ENV WDIR=/data
WORKDIR $WDIR
ADD run.sh $WDIR/run.sh

# TAG to be passed at build time through `--build-arg TAG=<PYPI_TAG>`. Default: None
ARG TAG=None
# We already installed gfal2 via dnf, so first install only non-gfal2 service dependencies
# FIXME: it is probably best to remove it from the requirements.txt file
RUN curl -ksLO https://raw.githubusercontent.com/dmwm/WMCore/$TAG/requirements.txt
RUN cat requirements.txt | grep dbs3-client > req.txt
RUN cat requirements.txt | grep msunmerged | grep -v gfal2 >> req.txt
# Create venv based on environment python,
# install modified requirements,
# and install MSUnmerged itself, without any dependencies
RUN python -m venv .venv && \
.venv/bin/pip install -r req.txt && \
.venv/bin/pip install --no-deps msunmerged==$TAG

# add venv to the path to use the proper python3
ENV PATH="/data/.venv/bin:$PATH"

# and now setup run.sh and manage scripts accordingly
RUN sed -i -e "s,-config.py,-config-unmerged.py,g" /data/run.sh
RUN sed -i -e "s,config.py,config-unmerged.py,g" /data/manage
ENV USER=_reqmgr2ms
RUN useradd ${USER} && install -o ${USER} -d ${WDIR}
RUN echo "%$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER ${USER}
RUN sudo chown -R $USER.$USER $WDIR
CMD ["python3"]