Skip to content

Commit 68b34ab

Browse files
committed
micromamba container has too many missing OS components to work correctly, switch to ubuntu setup
1 parent 5b88996 commit 68b34ab

2 files changed

Lines changed: 151 additions & 25 deletions

File tree

gromacs/.condarc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
2+
3+
auto_update_conda: false
4+
show_channel_urls: true
5+
channels:
6+
- conda-forge

gromacs/Dockerfile

Lines changed: 145 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,157 @@
1-
FROM ghcr.io/mamba-org/micromamba:2.4.0-ubuntu24.04
1+
ARG BASE_IMAGE=ubuntu:24.04
2+
FROM $BASE_IMAGE
23

34
LABEL maintainer="James Gebbie-Rayet <james.gebbie@stfc.ac.uk>"
45

5-
ARG AIIDAVERSION=2.6.1
6+
# Define customisable args
7+
ARG AIIDAVERSION=2.6.3
68
ARG GMXVERSION=2025.4
79
ARG PLUMEDVERSION=2.9.2
810
ARG PYTHONVERSION=3.11
9-
ARG NEW_MAMBA_USER=aiida
10-
ARG NEW_MAMBA_USER_ID=1001
11-
ARG NEW_MAMBA_USER_GID=121
11+
ARG SYSTEM_USER=aiida
12+
ARG SYSTEM_UID=1001
13+
ARG SYSTEM_GID=121
14+
15+
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
16+
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
17+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
18+
1219
USER root
1320

14-
RUN if grep -q '^ID=alpine$' /etc/os-release; then \
15-
# alpine does not have usermod/groupmod
16-
apk add --no-cache --virtual temp-packages shadow; \
17-
fi && \
18-
usermod "--login=${NEW_MAMBA_USER}" "--home=/home/${NEW_MAMBA_USER}" \
19-
--move-home "-u ${NEW_MAMBA_USER_ID}" "${MAMBA_USER}" && \
20-
groupmod "--new-name=${NEW_MAMBA_USER}" \
21-
"-g ${NEW_MAMBA_USER_GID}" "${MAMBA_USER}" && \
22-
if grep -q '^ID=alpine$' /etc/os-release; then \
23-
# remove the packages that were only needed for usermod/groupmod
24-
apk del temp-packages; \
21+
# Set OS level deps
22+
ENV DEBIAN_FRONTEND=noninteractive
23+
RUN apt-get update --yes && \
24+
apt-get upgrade --yes && \
25+
apt-get install --yes --no-install-recommends \
26+
bison \
27+
build-essential \
28+
bzip2 \
29+
ca-certificates \
30+
cmake \
31+
curl \
32+
flex \
33+
erlang \
34+
gfortran \
35+
git \
36+
libbz2-dev \
37+
locales \
38+
openssh-client \
39+
sudo \
40+
vim \
41+
wget \
42+
xz-utils \
43+
zlib1g-dev && \
44+
apt-get clean && rm -rf /var/lib/apt/lists/* && \
45+
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
46+
locale-gen
47+
48+
# Configure env vars
49+
ENV CONDA_DIR=/opt/conda \
50+
SHELL=/bin/bash \
51+
SYSTEM_USER="${SYSTEM_USER}" \
52+
SYSTEM_UID=${SYSTEM_UID} \
53+
SYSTEM_GID=${SYSTEM_GID} \
54+
LC_ALL=en_US.UTF-8 \
55+
LANG=en_US.UTF-8 \
56+
LANGUAGE=en_US.UTF-8
57+
ENV PATH="${CONDA_DIR}/bin:${PATH}" \
58+
HOME="/home/${SYSTEM_USER}"
59+
60+
# Create SYSTEM_USER with name aiida with UID=1001 and in the 'users' group
61+
# and make sure these dirs are writable by the `users` group.
62+
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
63+
sed -i.bak -e 's/^%admin/#%admin/' /etc/sudoers && \
64+
sed -i.bak -e 's/^%sudo/#%sudo/' /etc/sudoers && \
65+
addgroup --gid "${SYSTEM_GID}" "${SYSTEM_USER}" && \
66+
useradd -l -m -s /bin/bash -N --uid "${SYSTEM_UID}" --gid "${SYSTEM_GID}" "${SYSTEM_USER}" && \
67+
mkdir -p "${CONDA_DIR}" && \
68+
chown "${SYSTEM_USER}:${SYSTEM_GID}" "${CONDA_DIR}" "${HOME}" && \
69+
chmod g+w /etc/passwd
70+
71+
# make a github actions mount point.
72+
RUN mkdir /github && \
73+
chown "${SYSTEM_USER}:${SYSTEM_GID}" /github
74+
75+
USER ${SYSTEM_UID}
76+
77+
# Download and install Micromamba, and initialize Conda prefix.
78+
COPY --chown="${SYSTEM_UID}:${SYSTEM_GID}" .condarc "${CONDA_DIR}/.condarc"
79+
WORKDIR /tmp
80+
RUN set -x && \
81+
arch=$(uname -m) && \
82+
if [ "${arch}" = "x86_64" ]; then \
83+
# Should be simpler, see <https://github.com/mamba-org/mamba/issues/1437>
84+
arch="64"; \
2585
fi && \
26-
# Update the expected value of MAMBA_USER for the
27-
# _entrypoint.sh consistency check.
28-
echo "${NEW_MAMBA_USER}" > "/etc/arg_mamba_user" && \
29-
:
30-
ENV MAMBA_USER=$NEW_MAMBA_USER
31-
USER $MAMBA_USER
86+
wget --progress=dot:giga -O /tmp/micromamba.tar.bz2 \
87+
"https://micromamba.snakepit.net/api/micromamba/linux-${arch}/latest" && \
88+
tar -xvjf /tmp/micromamba.tar.bz2 --strip-components=1 bin/micromamba && \
89+
rm /tmp/micromamba.tar.bz2 && \
90+
./micromamba install \
91+
--root-prefix="${CONDA_DIR}" \
92+
--prefix="${CONDA_DIR}" \
93+
--yes \
94+
'mamba' && \
95+
rm micromamba
96+
97+
# Add ~/.local/bin to PATH where the dependencies get installed via pip
98+
# This require the package installed with `--user` flag in pip
99+
ENV PATH=${PATH}:/home/${SYSTEM_USER}/.local/bin
32100

33101
# Install dependencies
34-
RUN micromamba install -c conda-forge python=$PYTHONVERSION aiida-core=$AIIDAVERSION aiida-core.services=$AIIDAVERSION && \
35-
micromamba install -c conda-forge gromacs=$GMXVERSION plumed=$PLUMEDVERSION && \
36-
micromamba clean --all --yes
102+
RUN mamba install -c conda-forge mamba python=$PYTHONVERSION aiida-core=$AIIDAVERSION aiida-core.services=$AIIDAVERSION && \
103+
mamba clean --all --yes
104+
105+
# Change to root and build in /tmp.
106+
USER root
107+
WORKDIR /tmp
108+
109+
# Grab the specified version of plumed and untar the source.
110+
RUN wget https://github.com/plumed/plumed2/archive/refs/tags/v${PLUMEDVERSION}.tar.gz && \
111+
tar xvf v${PLUMEDVERSION}.tar.gz && \
112+
rm v${PLUMEDVERSION}.tar.gz
113+
114+
# Configure, compile and install plumed.
115+
WORKDIR /tmp/plumed2-${PLUMEDVERSION}
116+
RUN ./configure --prefix=/opt/plumed2-${PLUMEDVERSION}
117+
RUN make -j8
118+
RUN make install
119+
120+
# Add plumed to the various paths.
121+
ENV PATH=/opt/plumed2-${PLUMEDVERSION}/bin:$PATH
122+
ENV LIBRARY_PATH=/opt/plumed2-${PLUMEDVERSION}/lib:$LIBRARY_PATH
123+
ENV LD_LIBRARY_PATH=/opt/plumed2-${PLUMEDVERSION}/lib:$LD_LIBRARY_PATH
124+
ENV PLUMED_KERNEL=/opt/plumed2-${PLUMEDVERSION}/lib/libplumedKernel.so
125+
ENV PLUMED_VIMPATH=/opt/plumed2-${PLUMEDVERSION}/vim
126+
ENV PYTHONPATH=/opt/plumed2-${PLUMEDVERSION}/python:$PYTHONPATH
127+
128+
# Back to tmp
129+
WORKDIR /tmp
130+
131+
# Grab the specified version of gromacs and untar the source.
132+
RUN wget ftp://ftp.gromacs.org/gromacs/gromacs-${GMXVERSION}.tar.gz && \
133+
tar xvf gromacs-${GMXVERSION}.tar.gz && \
134+
rm gromacs-${GMXVERSION}.tar.gz
135+
136+
# Patch gmx with plumed and make build dir
137+
WORKDIR /tmp/gromacs-${GMXVERSION}
138+
#RUN plumed patch -p -e gromacs-2025.4
139+
RUN mkdir build
140+
141+
# Build gromacs without mpi and without cuda.
142+
WORKDIR /tmp/gromacs-${GMXVERSION}/build
143+
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gromacs-${GMXVERSION} -DGMX_BUILD_OWN_FFTW=ON -DGMX_OPENMP=ON -DGMXAPI=OFF -DCMAKE_BUILD_TYPE=Release
144+
145+
RUN make -j8
146+
RUN make install
147+
148+
# Cleanup and fix permissions.
149+
RUN rm -r /tmp/gromacs-${GMXVERSION}
150+
RUN chown ${SYSTEM_UID}:${SYSTEM_GID} -R /opt/gromacs-${GMXVERSION}
151+
152+
# Add the exec to the path.
153+
ENV PATH=/opt/gromacs-${GMXVERSION}/bin:$PATH
37154

155+
# Switch back to USER aiida to avoid accidental container runs as root
156+
USER ${SYSTEM_UID}
157+
WORKDIR "${HOME}"

0 commit comments

Comments
 (0)