for-linux icon indicating copy to clipboard operation
for-linux copied to clipboard

RUN usermod -u takes 45min during image building

Open ReHoss opened this issue 10 months ago • 0 comments

Hi,

First, sorry If it is not the right place to ask this question. In that case, please refer me where to submit my request.

Building a container with the Dockerfile below takes 45min at the usermod stage.

Is this behaviour normal? Note, firedrake-vanilla is a quite heavy image.

Best,

  • Build command:
docker build \
  --tag "$TAG_IMAGE" \
  --build-arg USER_ID="$(id -u)" \
  --build-arg GROUP_ID="$(id -g)" \
  --progress=plain \
  "$PATH_DOCKERFILE_DIR"
  • Dockerfile:
FROM firedrakeproject/firedrake-vanilla:latest
LABEL authors="hosseinkhan"


# Source the firedrake environment
ENV PATH_FIREDRAKE_VENV_ACTIVATION_SCRIPT=/home/firedrake/firedrake/bin/activate \
    URL_HYDROGYM=https://github.com/ReHoss/hydrogym.git@main

RUN /bin/bash -c "source $PATH_FIREDRAKE_VENV_ACTIVATION_SCRIPT && \
    pip install --upgrade pip && \
    pip install git+$URL_HYDROGYM && \
    pip install  \
    cma \
    colorednoise \
    gpflow \
    git+https://github.com/j-wilson/GPflowSampling.git@develop \
    gymnasium \
    jax \
    jaxlib \
    matplotlib \
    mlflow==1.27.0 \
    omegaconf \
    pystan \
    pyyaml \
    scikit-learn \
    scipy \
    tf_keras \
    tqdm"


# Create a directory for mounting
RUN mkdir -p /home/firedrake/mount_dir/project_root/


# PRINT THE CURRENT ENVIRONMENT TO THE TERMINAL
RUN /bin/bash -c "echo 'Current python: $(which python)' && \
    echo 'Current pip: $(which pip)' && \
    echo 'Current python version: $(python --version)' && \
    echo 'Current pip version: $(pip --version)' && \
    echo 'Current pip list: $(pip list)'"

# Firedrake change uid approach
USER root
ARG USER_ID
ARG GROUP_ID
RUN usermod -u $USER_ID firedrake
RUN groupmod -g $GROUP_ID firedrake

USER firedrake

ENTRYPOINT ["/bin/bash", "-l", "-c", "source /home/firedrake/firedrake/bin/activate && /bin/bash"]

ReHoss avatar Apr 09 '24 10:04 ReHoss