From 773585496e12a41d49f2f43a54b3e8668d342f2b Mon Sep 17 00:00:00 2001 From: Heather Turner Date: Thu, 17 Oct 2024 16:41:40 +0100 Subject: [PATCH 1/5] use ppa:marutter/rrutter4.0 as base R repository --- .gitpod.Dockerfile | 10 ++++++---- Dockerfile | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 1a4d0f99..e48507f1 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -13,13 +13,15 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ && rm -f /tmp/reinstall-cmake.sh RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list \ - && echo "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" >> /etc/apt/sources.list \ + && apt -y update \ + && apt install -y --no-install-recommends \ + software-properties-common \ + subversion \ + valgrind \ + && add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \ && wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \ - && apt update \ - && apt -y install subversion \ && apt -y build-dep r-base-dev \ && apt -y install r-base-dev \ - && apt -y install valgrind \ && Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \ && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" diff --git a/Dockerfile b/Dockerfile index 93f13364..1227fa8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,12 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ && rm -f /tmp/reinstall-cmake.sh RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list \ - && echo "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" >> /etc/apt/sources.list \ + && apt -y update \ + && apt install -y --no-install-recommends \ + software-properties-common \ + subversion \ + && add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \ && wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \ - && apt update \ - && apt -y install subversion \ && apt -y build-dep r-base-dev \ && apt -y install r-base-dev \ && Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \ From 5c0756188281664b4ee0102bf74493cfc2551815 Mon Sep 17 00:00:00 2001 From: Atharva Shirdhankar <72031540+StarTrooper08@users.noreply.github.com> Date: Fri, 18 Oct 2024 01:53:14 +0530 Subject: [PATCH 2/5] Update Dockerfile clean up the local cache of package lists --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1227fa8b..4913c2a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,8 @@ RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list \ && apt -y build-dep r-base-dev \ && apt -y install r-base-dev \ && Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \ - && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" + && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" \ + && rm -rf /var/lib/apt/lists/* RUN apt install shellcheck RUN apt install -y ccache From a794b17b33875bd63dc174ba26e9a4e1d15df6b9 Mon Sep 17 00:00:00 2001 From: Atharva Shirdhankar <72031540+StarTrooper08@users.noreply.github.com> Date: Fri, 18 Oct 2024 01:54:02 +0530 Subject: [PATCH 3/5] Update .gitpod.Dockerfile clean up the local cache of package lists --- .gitpod.Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index e48507f1..b59c6ddd 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -23,7 +23,8 @@ RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list \ && apt -y build-dep r-base-dev \ && apt -y install r-base-dev \ && Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \ - && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" + && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" \ + && rm -rf /var/lib/apt/lists/* RUN apt install -y shellcheck RUN apt install -y ccache From 37ff58100dd08bc8420646985a23180a56c458cb Mon Sep 17 00:00:00 2001 From: Atharva Date: Thu, 13 Feb 2025 00:06:24 +0530 Subject: [PATCH 4/5] multi-stage dockerfile: This reduces image size to half compare to earlier image version size --- Dockerfile | 73 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4913c2a5..6fce152e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM mcr.microsoft.com/devcontainers/cpp:dev-ubuntu-22.04 +# First Stage: Builder +FROM mcr.microsoft.com/devcontainers/cpp:dev-ubuntu-22.04 AS builder ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none" -# Optionally install the cmake for vcpkg +# Optionally install CMake for vcpkg COPY ./reinstall-cmake.sh /tmp/ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ @@ -10,25 +11,65 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ fi \ && rm -f /tmp/reinstall-cmake.sh -RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list \ - && apt -y update \ - && apt install -y --no-install-recommends \ +# Enable deb-src for dependencies +RUN sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list && apt update + +# Install necessary build dependencies +RUN apt install -y --no-install-recommends \ software-properties-common \ subversion \ - && add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \ - && wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \ + wget \ + gpg \ + build-essential \ + gfortran \ + libxml2-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + libblas-dev \ + liblapack-dev + +# Add R repository and install R +RUN add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \ + && wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \ + && apt update \ && apt -y build-dep r-base-dev \ - && apt -y install r-base-dev \ - && Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \ - && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" \ - && rm -rf /var/lib/apt/lists/* + && apt -y install r-base-dev -RUN apt install shellcheck -RUN apt install -y ccache -#RUN /usr/sbin/update-ccache-symlinks -#RUN echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a /home/vscode/.bashrc +# Install R packages +RUN Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \ + && Rscript -e "install.packages('httpgd', repos='https://cran.rstudio.com')" +# Install shellcheck and ccache +RUN apt install -y shellcheck ccache +# Second Stage: Final Image +FROM mcr.microsoft.com/devcontainers/cpp:dev-ubuntu-22.04 AS final ARG CONTAINER_VERSION -ENV CONTAINER_VERSION ${CONTAINER_VERSION} +ENV CONTAINER_VERSION=${CONTAINER_VERSION} + +# Install minimal runtime dependencies +RUN apt update && apt install -y --no-install-recommends \ + libxml2 \ + libcurl4-openssl-dev \ + libssl-dev \ + libblas-dev \ + liblapack-dev \ + gfortran + +# Copy R installation from builder stage +COPY --from=builder /usr/lib/R /usr/lib/R +COPY --from=builder /usr/bin/R /usr/bin/R +COPY --from=builder /usr/local/lib/R /usr/local/lib/R +COPY --from=builder /usr/share/R /usr/share/R +COPY --from=builder /etc/R /etc/R + +# Copy shared libraries +COPY --from=builder /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu + +# Set environment variables +ENV PATH="/usr/lib/R/bin:$PATH" +ENV LD_LIBRARY_PATH="/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu" + +# Verify installation +RUN ldconfig && R --version From e0857381afc582a1acfa3ca00ad6ea840fa82c2a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 09:19:14 +0000 Subject: [PATCH 5/5] [pre-commit.ci] Fixing issues with pre-commit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6fce152e..3aff9cb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ RUN add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \ && wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \ && apt update \ && apt -y build-dep r-base-dev \ - && apt -y install r-base-dev + && apt -y install r-base-dev # Install R packages RUN Rscript -e "install.packages('languageserver', repos='https://cran.rstudio.com')" \