From c953ad1c7359dbb4e7c9a0e8838a4d5bceb250b8 Mon Sep 17 00:00:00 2001 From: Adam Blake Date: Thu, 7 Mar 2024 16:24:13 -0800 Subject: [PATCH] chore: remove unused files and redundant stages --- base-r-notebook/Dockerfile | 9 ---- base-r-notebook/bin/copy-shared-libs | 62 ---------------------------- base-r-notebook/bin/diff-shared-libs | 14 ------- base-r-notebook/bin/find-shared-libs | 17 -------- datascience-notebook/Dockerfile | 19 +-------- essentials-notebook/Dockerfile | 1 - r-notebook/Dockerfile | 1 - 7 files changed, 2 insertions(+), 121 deletions(-) delete mode 100644 base-r-notebook/bin/copy-shared-libs delete mode 100644 base-r-notebook/bin/diff-shared-libs delete mode 100644 base-r-notebook/bin/find-shared-libs diff --git a/base-r-notebook/Dockerfile b/base-r-notebook/Dockerfile index 600312b..5cf5ca0 100644 --- a/base-r-notebook/Dockerfile +++ b/base-r-notebook/Dockerfile @@ -66,12 +66,3 @@ RUN --mount=type=cache,target=${CONDA_DIR}/pkgs,uid=${NB_UID},sharing=locked \ # add R mimetype and networking options COPY --chown=${NB_UID}:${NB_GID} Rprofile.site "${R_HOME}"/etc/ - -# add common utilities -USER root -COPY --chmod=555 bin/ /usr/local/bin/ -RUN chmod 555 \ - /usr/local/bin/find-shared-libs \ - /usr/local/bin/diff-shared-libs \ - /usr/local/bin/copy-shared-libs -USER ${NB_UID} diff --git a/base-r-notebook/bin/copy-shared-libs b/base-r-notebook/bin/copy-shared-libs deleted file mode 100644 index f434d90..0000000 --- a/base-r-notebook/bin/copy-shared-libs +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - - -# Don't run this outside of a container --- it is designed to overwrite files. - - -isDocker(){ - local cgroup=/proc/1/cgroup - test -f $cgroup && [[ "$(<$cgroup)" = *:cpuset:/docker/* ]] -} - -isDockerBuildkit(){ - local cgroup=/proc/1/cgroup - test -f $cgroup && [[ "$(<$cgroup)" = *:cpuset:/docker/buildkit/* ]] -} - -isDockerContainer(){ - [ -e /.dockerenv ] -} - -if isDockerBuildkit || (isDocker && ! isDockerContainer) -then - echo "This script is not designed to be run outside of a container." - exit 1 -fi - - - -# Check for correct number of arguments -if [ "$#" -ne 3 ]; then - echo "Usage: $0 " - exit 1 -fi - -PATHS_FILE=$1 -MOUNT_DIR=$2 -OUTPUT_DIR=$3 - -# Ensure that the mount directory exists -if [ ! -d "${MOUNT_DIR}" ]; then - echo "Mount directory does not exist: ${MOUNT_DIR}" - exit 1 -fi - -# Ensure that the paths file only contains absolute paths -if grep -q -v "^/" ${PATHS_FILE}; then - echo "Paths file contains relative paths" - exit 1 -fi - -# Trim trailing slashes from the mount directory if they exist -MOUNT_DIR=${MOUNT_DIR%/} - -# If the output directory does not exist, create it -if [ ! -d "${OUTPUT_DIR}" ]; then - mkdir -p "${OUTPUT_DIR%/}" -fi - -while read -r line; do - mounted_path="${MOUNT_DIR}${line}" - cp -RL "${mounted_path}" "${line}" -done < "${PATHS_FILE}" diff --git a/base-r-notebook/bin/diff-shared-libs b/base-r-notebook/bin/diff-shared-libs deleted file mode 100644 index a4e0bb7..0000000 --- a/base-r-notebook/bin/diff-shared-libs +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Check for correct number of arguments -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Input file paths for the lists of shared libraries to compare -PREVIOUS_LIBS_FILE=$1 -CURRENT_LIBS_FILE=$2 - -# Output new shared libraries that are in the current list but not in the previous one -comm -13 <(sort -u ${PREVIOUS_LIBS_FILE}) <(sort -u ${CURRENT_LIBS_FILE}) diff --git a/base-r-notebook/bin/find-shared-libs b/base-r-notebook/bin/find-shared-libs deleted file mode 100644 index 79235b4..0000000 --- a/base-r-notebook/bin/find-shared-libs +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Check for correct number of arguments -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Binary files to search for shared libraries -R_LIBS_DIR=$1 - -# Generate a list of shared libraries required by R packages -ldd ${R_LIBS_DIR}/*/libs/*.so | \ - grep "=> /" | \ - awk '{print $3}' | \ - xargs realpath --no-symlinks | \ - sort -u diff --git a/datascience-notebook/Dockerfile b/datascience-notebook/Dockerfile index 114e32b..1a7c9a6 100644 --- a/datascience-notebook/Dockerfile +++ b/datascience-notebook/Dockerfile @@ -15,26 +15,11 @@ ARG PIP_CACHE_DIR=/tmp/pip-cache ARG PIP_WHEEL_DIR=/tmp/pip-wheels ARG APT_CACHE_DIR=/var/cache/apt ARG APT_LIB_DIR=/var/lib/apt -ARG SHARED_LIBS_LIST=/tmp/shared-libs.txt - - -# base -# ------------------------------------- -FROM ${PARENT_IMAGE} as base - -# install cmdstan dependencies -USER root -ARG APT_CACHE_DIR APT_LIB_DIR -RUN --mount=type=cache,target="${APT_CACHE_DIR}",sharing=locked \ - --mount=type=cache,target="${APT_LIB_DIR}",sharing=locked \ - apt-get update && apt-get upgrade -y && apt-get -y install --no-install-recommends \ - g++ -USER ${NB_UID} # py-builder # ------------------------------------- -FROM base as py-builder +FROM ${PARENT_IMAGE} as py-builder RUN --mount=type=cache,target=${CONDA_DIR}/pkgs,uid=${NB_UID},sharing=locked \ mamba install --yes "gdal" @@ -49,7 +34,7 @@ RUN --mount=type=bind,source="${PY_REQUIREMENTS}",target=/tmp/requirements.txt \ # final # ------------------------------------- -FROM base +FROM ${PARENT_IMAGE} as base LABEL maintainer="CourseKata " # install cmdstan and related requests diff --git a/essentials-notebook/Dockerfile b/essentials-notebook/Dockerfile index 0f61220..eabbf01 100644 --- a/essentials-notebook/Dockerfile +++ b/essentials-notebook/Dockerfile @@ -16,7 +16,6 @@ ARG PIP_CACHE_DIR=/tmp/pip-cache ARG PIP_WHEEL_DIR=/tmp/pip-wheels ARG APT_CACHE_DIR=/var/cache/apt ARG APT_LIB_DIR=/var/lib/apt -ARG SHARED_LIBS_LIST=/tmp/shared-libs.txt # py-builder diff --git a/r-notebook/Dockerfile b/r-notebook/Dockerfile index e9e05de..552c207 100644 --- a/r-notebook/Dockerfile +++ b/r-notebook/Dockerfile @@ -17,7 +17,6 @@ ARG PIP_CACHE_DIR=/tmp/pip-cache ARG PIP_WHEEL_DIR=/tmp/pip-wheels ARG APT_CACHE_DIR=/var/cache/apt ARG APT_LIB_DIR=/var/lib/apt -ARG SHARED_LIBS_LIST=/tmp/shared-libs.txt # py-builder