Skip to content

Commit

Permalink
fix Java install in devcontainer
Browse files Browse the repository at this point in the history
It was downloading and installing `debuginfo`...

Since it's fixed, I can also remove `--disable-java` from GNU-R `./configure`.

Lastly, GNU-R needs `gfortran` at runtime.
  • Loading branch information
Jakobeha committed Aug 2, 2024
1 parent dc256d4 commit 8fb1b0f
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# This Dockerfile uses separate build arguments instead of VARIANT
# TODO: Abstract distribution and version however much is possible.
# The download URL doesn't make this easy.
# ARG TARGET_JAVA_DISTIBUTION=temurin
# ARG TARGET_JAVA_VERSION=22
ARG TARGET_JAVA_VERSION=22.0.2+9
ARG TARGET_GNUR_VERSION=4.3.2
ARG TARGET_DEBIAN_VERSION=bookworm
FROM mcr.microsoft.com/devcontainers/base:${TARGET_DEBIAN_VERSION}
FROM mcr.microsoft.com/devcontainers/base:$TARGET_DEBIAN_VERSION

USER root
# ARG TARGET_JAVA_DISTIBUTION
# ARG TARGET_JAVA_VERSION
ARG TARGET_JAVA_VERSION
ARG TARGET_GNUR_VERSION
ENV JAVA_HOME=/usr/lib/jvm/jdk
ENV PATH="${JAVA_HOME}/bin:${PATH}"
ENV PATH="$JAVA_HOME/bin:$PATH"
# Default to UTF-8 file.encoding
ENV LANG=en_US.UTF-8

Expand All @@ -27,13 +23,13 @@ RUN arch="$(dpkg --print-architecture)" \
;; \
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
esac \
&& jdkUrl="https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.2%2B9/OpenJDK22U-debugimage_${arch1}_linux_hotspot_22.0.2_9.tar.gz" \
&& wget --progress=dot:giga -O temurin.tar.gz "${jdkUrl}" \
&& wget --progress=dot:giga -O sha256.txt "${jdkUrl}.sha256.txt"
&& jdkUrl="https://github.com/adoptium/temurin22-binaries/releases/download/jdk-$TARGET_JAVA_VERSION/OpenJDK22U-jdk_${arch1}_linux_hotspot_$(echo $TARGET_JAVA_VERSION | tr '+' '_').tar.gz" \
&& wget --progress=dot:giga -O temurin.tar.gz "$jdkUrl" \
&& wget --progress=dot:giga -O sha256.txt "$jdkUrl.sha256.txt"

RUN sha256Text=$(cat sha256.txt) \
&& sha256=$(expr substr "${sha256Text}" 1 64) \
&& echo "${sha256} temurin.tar.gz" | sha256sum --strict --check - \
&& sha256=$(expr substr "$sha256Text" 1 64) \
&& echo "$sha256 temurin.tar.gz" | sha256sum --strict --check - \
&& rm sha256.txt*

RUN mkdir -p "$JAVA_HOME"
Expand All @@ -44,15 +40,16 @@ RUN tar --extract \
--no-same-owner
RUN rm temurin.tar.gz*

RUN ln -s ${JAVA_HOME} /docker-java-home
RUN ln -s ${JAVA_HOME} /usr/local/openjdk-${TARGET_JAVA_VERSION}
RUN ln -s $JAVA_HOME /docker-java-home
RUN ln -s $JAVA_HOME /usr/local/openjdk-$(echo $TARGET_JAVA_VERSION | cut -d'-' -f1)

# Install GNU-R
# From https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Essential-and-useful-other-programs-under-a-Unix_002dalike
ARG GNUR_DEPENDENCIES="build-essential gfortran libreadline-dev zlib1g-dev libbz2-dev liblzma-dev libpcre2-dev"
ARG GNUR_RUNTIME_DEPENDENCIES="build-essential gfortran"
ARG GNUR_BUILD_DEPENDENCIES="libreadline-dev zlib1g-dev libbz2-dev liblzma-dev libpcre2-dev"

RUN gnurUrl="https://cloud.r-project.org/src/base/R-$(printf %.1s ${TARGET_GNUR_VERSION})/R-${TARGET_GNUR_VERSION}.tar.gz" \
&& wget --progress=dot:giga -O gnur.tar.gz "${gnurUrl}"
RUN gnurUrl="https://cloud.r-project.org/src/base/R-$(printf %.1s $TARGET_GNUR_VERSION)/R-$TARGET_GNUR_VERSION.tar.gz" \
&& wget --progress=dot:giga -O gnur.tar.gz "$gnurUrl"

RUN mkdir -p /tmp/gnur
RUN tar --extract \
Expand All @@ -62,19 +59,19 @@ RUN tar --extract \
--no-same-owner
RUN rm gnur.tar.gz*

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends ${GNUR_DEPENDENCIES}
RUN DEBIAN_FRONTEND=noninteractive apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends $GNUR_BUILD_DEPENDENCIES $GNUR_RUNTIME_DEPENDENCIES

# `--disable-java` is because (for some reason, it's clearly set above) R can't find `JAVA_HOME`.
# We don't use the Java support in R, so for now, instead of fixing that issue we disable it.
RUN cd /tmp/gnur \
&& ./tools/rsync-recommended \
&& ./configure --prefix=/usr/local --disable-java --with-x=no \
&& ./configure --prefix=/usr/local --with-x=no \
&& make \
&& make install
RUN rm -rf /tmp/gnur

RUN apt-get -y remove --purge ${GNUR_DEPENDENCIES}
RUN DEBIAN_FRONTEND=noninteractive apt-get -y remove --purge $GNUR_BUILD_DEPENDENCIES
# Fortran is needed at
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends gfortran
RUN DEBIAN_FRONTEND=noninteractive apt-get -y autoremove

# [Optional] Uncomment this section to install additional OS packages.
Expand Down

0 comments on commit 8fb1b0f

Please sign in to comment.