diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index 5cc82e3d9..c3205ec4f 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -8,10 +8,6 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # original archive showed performance issues and is farther away RUN sed -i 's|^deb http://archive|deb http://fr.archive|g' /etc/apt/sources.list -COPY ./script/make_utils/setup_os_deps.sh ./setup_os_deps.sh -COPY ./script/make_utils/detect_docker.sh ./detect_docker.sh -RUN ./setup_os_deps.sh --linux-install-python && rm ./setup_os_deps.sh && rm ./detect_docker.sh - ENV SRC_DIR=/src # Default to Ubuntu default uid for first user @@ -20,7 +16,7 @@ ARG BUILD_UID=1000 # Get sudo and vim for our future user RUN apt-get update && \ - apt-get install --no-install-recommends -y sudo vim && \ + apt-get install --no-install-recommends -y sudo vim adduser && \ rm -rf /var/lib/apt/lists/* # For ubuntu>23 the ubuntu user will exist and use uid/gid=1000 @@ -41,15 +37,14 @@ RUN groupadd -f -g "${BUILD_GID}" dev_user && \ chown dev_user "${SRC_DIR}" && \ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN groupadd docker && usermod -aG docker dev_user + # Now switch to the newly created user USER dev_user -RUN (pipx install poetry && pipx ensurepath) || \ - (\ - python3 -m pip install --no-cache-dir --upgrade pip && \ - python3 -m pip install --no-cache-dir --ignore-installed poetry==1.7.1 && \ - echo 'PATH=$PATH:/home/dev_user/.local/bin/' >> ~/.bashrc \ - ) +COPY ./script/make_utils/setup_os_deps.sh ./setup_os_deps.sh +COPY ./script/make_utils/detect_docker.sh ./detect_docker.sh +RUN ./setup_os_deps.sh --linux-install-python && sudo rm ./setup_os_deps.sh && sudo rm ./detect_docker.sh RUN echo "source ~/dev_venv/bin/activate" >> ~/.bashrc && \ echo "if [[ \"\$?\" != \"0\" ]]; then" >> ~/.bashrc && \ diff --git a/script/make_utils/setup_os_deps.sh b/script/make_utils/setup_os_deps.sh index c82fef302..e1083ae93 100755 --- a/script/make_utils/setup_os_deps.sh +++ b/script/make_utils/setup_os_deps.sh @@ -93,17 +93,12 @@ OS_NAME=$(uname) if [[ "${OS_NAME}" == "Linux" ]]; then # Docker build - if isDockerBuildkit || (isDocker && ! isDockerContainer); then - CLEAR_APT_LISTS="rm -rf /var/lib/apt/lists/* &&" - SUDO_BIN="" - else - CLEAR_APT_LISTS="" - SUDO_BIN="$(command -v sudo)" - if [[ "${SUDO_BIN}" != "" ]]; then - SUDO_BIN="${SUDO_BIN} " - fi + CLEAR_APT_LISTS="" + SUDO_BIN="$(command -v sudo)" + if [[ "${SUDO_BIN}" != "" ]]; then + SUDO_BIN="${SUDO_BIN} " fi - + PYTHON_PACKAGES= if [[ "${LINUX_INSTALL_PYTHON}" == "1" ]]; then PYTHON_PACKAGES="python3-pip \ @@ -119,7 +114,8 @@ if [[ "${OS_NAME}" == "Linux" ]]; then then SETUP_CMD="linux_install_actionlint" else - SETUP_CMD="${SUDO_BIN:+$SUDO_BIN}apt-get update && apt-get upgrade --no-install-recommends -y && \ + SETUP_CMD="${SUDO_BIN:+$SUDO_BIN}apt-get update && \ + ${SUDO_BIN:+$SUDO_BIN}apt-get upgrade --no-install-recommends -y && \ ${SUDO_BIN:+$SUDO_BIN}apt-get install --no-install-recommends -y \ build-essential \ curl \ @@ -136,22 +132,20 @@ if [[ "${OS_NAME}" == "Linux" ]]; then openssl \ shellcheck \ texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-xetex lmodern \ - wget pipx adduser && + wget pipx && ${CLEAR_APT_LISTS:+$CLEAR_APT_LISTS} \ - linux_install_gitleaks && linux_install_actionlint && linux_install_github_cli" + ${SUDO_BIN:+$SUDO_BIN} linux_install_gitleaks && \ + ${SUDO_BIN:+$SUDO_BIN} linux_install_actionlint && \ + ${SUDO_BIN:+$SUDO_BIN} linux_install_github_cli" fi eval "${SETUP_CMD}" - # If this is a CI build, install poetry (installs as root) - # if not, the Dockerfile installs poetry for docker builds (under dev_user) - if !isDockerBuildkit; then - (pipx install poetry && pipx ensurepath) || \ - (\ - python3 -m pip install --no-cache-dir --upgrade pip && \ - python3 -m pip install --no-cache-dir --ignore-installed poetry==1.7.1 && \ - echo 'PATH=$PATH:/home/dev_user/.local/bin/' >> ~/.bashrc \ - ) - fi + (pipx install poetry && pipx ensurepath) || \ + (\ + python3 -m pip install --no-cache-dir --upgrade pip && \ + python3 -m pip install --no-cache-dir --ignore-installed poetry==1.7.1 \ + ); + echo 'PATH=$PATH:/home/dev_user/.local/bin/' >> ~/.bashrc elif [[ "${OS_NAME}" == "Darwin" ]]; then # Some problems with the git which is preinstalled on AWS virtual machines. Let's unlink it